AUSTIN (KXAN) — A federal judge spent hours questioning and reprimanding Texas officials over an escalating crisis in the state’s foster care system, as hundreds of children are still sleeping in offices and hotels.

“I understand you are trying, but it’s not working,” U.S. District Judge Janis Jack told officials at the Texas Department of Family and Protective Services (DFPS).

Her comments were made in a hearing Tuesday morning — the latest development in the decade-long class-action lawsuit that ultimately brought the state system under federal court supervision. Judge Jack initially found the state had violated the constitutional rights of foster children and placed them in unsafe homes and facilities. She issued a list of reforms, and since then, has found Texas in contempt multiple times for not meeting those reforms.

According to a report released this week by the group of independent court monitors overseeing the federal lawsuit, 501 children spent at least one night in an unlicensed placement in the first half of this year alone. Some children spent more than 100 consecutive nights without a “proper” placement. The report found that 86% of these children were teenagers, and many of them require intense or specialized care, due to serious mental health needs or past trauma, that they likely weren’t receiving.

The report also noted Texas has lost more than 1,600 foster beds since January 2020, and DFPS officials have continually pointed to this loss of foster beds and treatment center closures as their reason for lacking placements for high-needs children.

“I’ll remind you, the state has closed these facilities because they were not safe,” the judge told DFPS Commissioner Jamie Masters. “I’ve watched your PR campaign that the court, COVID and, most egregiously, these children in your care are to blame.”

Judge Jack went on, “You have known for decades about the capacity crisis in the state for foster care children and not planned accordingly… Do something better for them, to keep them safe.”

Before her sworn testimony began , Masters noted, “I feel like anything I am going to offer will sound like an excuse.”

Judge Jack agreed and added, “I’m sure you have multiple excuses, but I don’t want to hear them right now.”

Masters told the court she didn’t regret any of the closures they had made. Still, she argued that oftentimes it’s more difficult than just finding a safe placement for the children, but rather finding the “appropriate” level of care.

“We have to fill that gap between our psychiatric hospitals and our RTCs [residential treatment centers],” she said.

At one point Masters told the court she had “failed these kids.”

Judge Jack and Paul Yetter, the attorney representing the thousands of Texas foster children, continually asked the Commissioner to admit that offices and hotels were not safe or appropriate alternatives. Ultimately, the judge called on the parties to all sit down and come up with “workable” solutions, outside the courtroom.

Then, she asked the attorneys representing the state for Gov. Greg Abbott’s blessing.

“I’m not interested in sanctions or putting feet to the fire anymore. I just want these children to be safe,” the judge said. “I think he shares that goal.”