Negotiations are underway between the U.S. government and immigration advocates over family detention after a federal judge issued a tentative ruling that detention facilities violate standards for children.

The result of the talks could force the three family detention centers operating in the U.S. — two in Texas and one in Berks County, Pa. — to close.

In Berks County, a teacher shouts out U.S. states, quizzing her 14 students on their capitals. The kids lift their hands and shout out the answers. In this classroom, students' ages range from five to 12. Most are from Central America and many have been detained at the Berks County Center anywhere between six months and a year.

Michelle Brane, director of the Migrant Rights and Justice Program at the Women's Refugee Commission, says that's a problem.

"We worry this has permanent effects on these children's both mental and physical health," she says.

A few years ago, parents and children would spend just a few weeks at Berks before being released.The majority then stayed with family members while their cases moved through immigration court.

But now, after tens of thousands of Central Americans fled violence in their home countries and surrendered at the U.S. border last summer, places like Berks began detaining families for much longer periods.

"It's being treated as a final destination with the objective of deterring migration," Brane says.

Under federal law, children who come to the United States without legal permission can be detained, but only for a short time before being released to a parent or guardian. But if children come over with a parent, the federal government says it reserves the right to keep them for longer stretches, in some cases more than a year.

That's being challenged in court. Last month a federal judge issued a tentative ruling against the government. She determined family detention centers don't meet standards for holding migrant children.

Advocates and government attorneys are now in mandated negotiations that could lead to major changes in the way migrant families are detained. Those changes could include closing family detention centers altogether.

Brane says she's "hopeful that these negotiations will come out to minimize the use of detention."

But Immigration and Customs Enforcement are defending the use of family detention. Agency staff point out that facilities are equipped with classrooms, playrooms, and provide on-site medical care. In a written statement, an agency spokesperson characterized the centers as an effective and humane way to keep families together as their cases are heard.

NPR recently toured the Berks facility but were not permitted to speak with any of the detainees. The dormitories are spartan, but clean. Cribs sit alongside single beds, rooms hold up to six people.

"No one is saying Berks is a gulag," says Matthew Archambeault, an immigration attorney who has represented detainees at Berks. He points out that even if the physical grounds don't look like a prison, these adults and children are still essentially imprisoned.

And that means center employees — not parents — are ultimately in control. Archambeault says that undermines a child's sense of security.

"So if their child is running and laughing, and the guard yells at them to be quiet, what can the mother or father say," he says. "They are prisoners, and that guard is the one that is in charge."

For now, there are plans to expand the Berks facility, doubling its capacity to about 200 people. The federal government pays the county $275 per detainee, per day.

The two centers in Texas are run by private corporations. Combined, they could end up holding roughly 3,000 parents and children. But that won't happen if they end up being shut down.

The judge has given the government and immigration advocates 30 days to try to come to an agreement.