The Justice Center jail in Syracuse, N.Y., won’t be putting children in isolation any longer.

Last week, a U.S. District Judge ordered the Justice Center to immediately stop putting children in solitary confinement for 23 hours a day. The New York Civil Liberties Union and Legal Services of Central New York filed a lawsuit to stop the Justice Center from subjecting teenagers to solitary confinement and other forms of punishment the jail uses. Judge David Hurd granted a preliminary injunction while the case proceeds, which includes engaging juveniles in social interactions that are meaningful and can’t harm their psychological health.

The court found that the Justice Center’s use of solitary confinement for children could violate the Eighth Amendment protection against cruel and unsual punishment.

The NYCLU and LSCNY filed a lawsuit against the Onondaga County Sheriff’s Office in September. According to the lawsuit, many of those placed in solitary confinement were mentally ill and in solitary for months at a time. They were allegedly sexually harassed by adults, lived in bad conditions and denied education, and some allegedly contemplated suicide. According to the NYCLU and LSCNY, children were sent to solitary confinement for speaking loudly or wearing the wrong shoes.

“Solitary confinement for children is torture and causes life-long damage,” said Donna Lieberman, executive director at the NYCLU, in a statement. “We are thrilled the children at the Justice Center will be removed from solitary for their safety and well-being.”

“We are ecstatic with Judge Hurd’s decision which will stop this torturous practice for the duration of our lawsuit,” added Josh Cotter, co-counsel on the case and a staff attorney at Legal Services of Central New York, in a statement. “It is our hope that the sheriff’s office and school district will now work with us to develop a long-term solution to this problem.”

According to the lawsuit, the NYCLU and LSCNY also accused the district of violating the children’s rights to an education while they are locked up. Judge Hurd denied the Onondaga School District’s request to be dismissed from the case and granted the injunction after checking to see that the plaintiffs were likely to win their case.

“Putting children in solitary is a grave injustice,” stated Phil Desgranges, staff attorney at the NYCLU and lead counsel on the case. “This decision makes clear that locking children in isolation endangers their mental health and is an unacceptable practice.”