A federal judge has ordered the Army Corps of Engineers to redo its study that approved a permit for a new cruise terminal in downtown Charleston.

U.S. District Court Judge Richard Gergel said the federal agency did not study all aspects when it awarded a permit last year for five pilings to construct the $35 million terminal at Union Pier.

“The scope of the analysis was done wrong,” Gergel said in court on Thursday. The S.C. State Ports Authority wants to build a new cruise terminal to replace an aging one already at Union Pier. The pilings are needed to convert a former warehouse into the new terminal.

Gergel made the decision after hearing nearly two hours of oral arguments between lawyers in downtown Charleston.

The Coastal Conservation League and the Preservation Society of Charleston are suing the Army Corps over the federal permit, saying partly that the Army Corps didn’t take into account the effect on historical properties.

Gergel sided with the groups on Thursday, saying the Army Corps should have looked at the historical and environmental concerns when it approved the project.

This marks one of three lawsuits opposing expanded cruises in downtown Charleston.