HOUSTON (AP)  An appeals court on Wednesday upheld most of a federal judge”s ruling that the bail system in Texas” most populous county was unconstitutional for people arrested for lesser offenses.

In its ruling, the 5th U.S. Circuit Court of Appeals agreed with U.S. District Judge Lee Rosenthal”s conclusion that Harris County”s bail system violated due process and equal protection measures of the U.S. Constitution. Harris County is home to Houston, the nation”s fourth largest city.

Last year, Rosenthal ruled as part of a lawsuit that the county”s policy of detaining indigent misdemeanor defendants before trial violated equal protection rights against wealth-based discrimination.

In its 26-page ruling, the New Orleans-based appeals court found that if you took two misdemeanor defendants in Harris County who were identical in every way, except that one is wealthy and one indigent, they would have different experiences as one would be able to post bond and the other not.

“As a result, the wealthy arrestee is less likely to plead guilty, more likely to receive a shorter sentence or be acquitted, and less likely to bear the social coast of incarceration,” the three-judge panel wrote. “The poor arrestee, by contrast, must bear the brunt of all of these, simply because he has less money than his wealthy counterpart. The district court held that this state of affairs violates the equal protection clause, and we agree.”

However, the appeals court ordered Rosenthal to revise a preliminary injunction she had issued that ordered the county to release indigent inmates without posting cash bail while they await trial on misdemeanor offenses.

The appeals court said the injunction was overbroad and Rosenthal”s requirement that indigent defendants be released within 24 hours of their arrest was too strict.

The appeals court also ordered that the sheriff in Harris County be released as a defendant in the lawsuit.

The lawsuit was filed by two civil rights groups and a Houston law firm on behalf of several misdemeanor defendants, including a woman who was jailed for two days for driving without a valid license because she couldn”t afford her $2,500 bail. The lawsuit, which is similar to others filed across the country, is a part of a broader push in the U.S. for bail-reform measures.

Alec Karakatsanis, executive director of Civil Rights Corps, one of the civil rights groups that filed the lawsuit, said the ruling “strongly reaffirmed” that the county”s bail system is unconstitutional.

“We will evaluate the next steps for helping Harris County craft a system that does not violate the Constitution and devastate tens of thousands of human beings and their families every year,” Karakatsanis said in a statement.

First Assistant County Attorney Robert Soard said the county was pleased with how the appeals court”s ruling reaffirmed that it”s the responsibility of county judicial officers to determine the terms and conditions of release of misdemeanor defendants.

County officials had expressed concerns that they were being forced to release potentially dangerous people from jail under Rosenthal”s injunction.

“Now, instead of immediate release after 24 hours without regard for risk to the community, Harris County … judges retain discretion regarding release provided a hearing for the defendant occurs within 48 hours after arrest,” Soard said in a statement.

Soard said the county has been “working diligently to improve the criminal justice system” and the county remains committed to settling the lawsuit.

While the county has spent more than $5 million fighting the lawsuit, some of its top officials, including the district attorney and the sheriff, are in support of bail reform efforts.

“The ruling is a significant victory for justice and offers further proof that it is time for Harris County to settle this lawsuit and enact meaningful reforms that treat all people equally and fairly under the law,” Harris County Commissioner Rodney Ellis said in a statement.