The surge of mothers crossing the Mexican border last summer with their children, but without permission, sorely tested the federal government’s immigration detention system. Immigration and Customs Enforcement (ICE) officials then exacerbated the problem by detaining hundreds of them as an example to others of what would happen if they made the same dangerous trip from Central America to the U.S.

A federal judge this year rightly ordered the government to stop using detention as a deterrent, and the government ended the practice. Still, and even though the flow across the border has ebbed, ICE holds upward of 1,400 mothers and children in three detention centers while investigators determine whether they have sufficient grounds to seek permission to stay.

U.S. District Judge Dolly M. Gee ruled last month that detaining those children in what she found to be “deplorable” conditions violated the 1997 Flores vs. Meese settlement, in which the government agreed to hold detained minors in nonprison settings licensed to care for children.

Gee made the right call; it is unconscionable to imprison children simply because their mothers are trying to find a better life for them. The government, which argues that it has improved conditions in the detention centers, last week asked Gee to reconsider her ruling. She shouldn’t.

What’s more, the government should stop defending this indefensible practice and find smarter, more humane ways to house those seeking legal permission to remain in the country.