A federal judge is demanding changes to a criminal justice system in St. Louis that can leave people stuck in jail for weeks when they don't have money for bail.

The plaintiffs, four inmates in St. Louis' City Workhouse medium security prison, had found themselves stuck behind bars not because they were flight risks or dangers to the community but because they could not afford bail. The judges wouldn't consider their financial situations or reconsider their bail amounts unless they were represented by counsel. For poor defendants who can't afford their own lawyers, it can take weeks before they were assigned a public defender.

Represented by several civil rights organizations, the inmates sued in January, arguing that their constitutional rights were violated by a pretrial detention system that cared more about extracting defendants' money than keeping the public safe. The lawsuit sought class-action status and an injunction ordering judges to stop detaining people purely on the basis of whether they could afford bail.

About 85 percent of people locked up in St. Louis are there because they found bail unaffordable. The data show that this wasn't really protecting public safety. According to evidence presented by the plaintiffs, a random sample of St. Louis cases found that when defendants did eventually receive a bail reduction hearing (after an average of 47 days in detention), 69 percent of them received a reduction in bail demands or were released on their own recognizance. In other words, once a judge finally got around to actually considering whether these defendants were dangers, he or she realized they probably were not—or at least not such dangers as to justify such high bail demands.

On Tuesday, Judge Audrey Fleissig of the U.S. District Court for the Eastern District of Missouri ruled in the plaintiffs' favor. Her preliminary injunction forbids the St. Louis jail system from detaining people for weeks on the sole basis of an inability to afford bail. Instead, defendants must be granted a hearing within 48 hours to give the accused an opportunity to request release. If the court wants to institute financial conditions, the court must determine the defendant's ability to pay bail and must show that no other release conditions would "reasonably assure the arrestee's future court appearance or the safety of others." For those who are currently in pretrial detention, the court has a week to give them new hearings.

Fleissig also ruled in favor of the request for class certification, meaning other people being held in jail in St. Louis can now join this lawsuit as it moves forward.

"At this very moment, there are hundreds of people detained in the City of St. Louis merely because of their poverty," responded Blake Strode, executive director of ArchCity Defenders, in a statement issued Tuesday. "Today's decision to grant a preliminary injunction is a critical first step in ending the current status quo of wealth-based detention."

The ruling is one of many recent wins over the past two years for a movement pushing for bail reforms. Bail is supposed to be a mechanism to guarantee that defendants return to court, not a reason to leave them stuck behind bars. But St. Louis is hardly alone: Many court systems blindly adhere to set bail schedules as a time-saver. People who get arrested are given flat bail amounts based on the severity of the crime. If they cannot pay, they just end up sitting in jail until they can convince a judge to let them out or show them mercy, and that can take weeks. As a result, hundreds of thousands of poor people across the country are in jail merely because they have been charged with crimes and not because they have been convicted.

In the decision, Fleissig took special note of the consequences when people end up detained in jail simply because they couldn't afford the money asked of them to make bail. "The threat of irreparable harm to the [defendants] is obvious," she wrote, "not only in the form of prolonged incarceration itself, but also in the form of its severe collateral consequences such as physical illness and injury, mental trauma, loss of employment, loss of benefits, and family crisis."

Read more about the bail reform push here. If you're in the San Francisco area this weekend and care about bail and other criminal justice reform issues, I'll be participating in a panel hosted by the city's Libertarian Party on Saturday evening. More details on that can be found here. Admission is free.