LOS ANGELES (CNS) — Los Angeles County has wrongly canceled Medi-Cal coverage for thousands of residents, often leaving them without access to healthcare and needed medicines, a judge has ruled.

In a decision on May 10, L.A. County Superior Court Judge James C. Chalfant wrote that the county violated state law by terminating Medi-Cal coverage for beneficiaries even though they turned in their renewal paperwork on time, the Los Angeles Times reported. The ruling orders the county to fix the problem.

About 3.9 million people in Los Angeles County rely on Medi-Cal for health coverage, according to state data. Medi-Cal, the state’s version of Medicaid, is funded is funded by the state and federal government and provides coverage to low-income Americans and people who are disabled.

From December 2016 to December 2017, about 22,000 people in LA County wrongly lost Medi-Cal benefits, according to evidence cited in the judge’s decision. The problems appear to have resulted from a backlog of applications and a faulty computer system, according to court documents cited by The Times.

“We hope that now the county will no longer be yanking Medi-Cal from over 2,000 patients a month, and that patients in our county who desperately need this life-sustaining Medi-Cal coverage will be able to keep it,” said David Kane, an attorney with the nonprofit Neighborhood Legal Services of Los Angeles County in remarks cited by The Times.

The ruling came in a lawsuit filed in December 2016 by several Medi-Cal beneficiaries represented by Neighborhood Legal Services and other firms.

Carol Northern, one of the plaintiffs, said she was skeptical yet hopeful that the county would change its practices, The Times reported. Northern, who has a blood disease that requires several medicines, was kicked off Medi-Cal in 2016 even though she completed her renewal packet on time, she said.

The judge found that the county had failed to uphold state law. A final judgment that includes a plan for how the county will fix the problem will be rendered in the next few months. Once the judgment is finalized, county lawyers can appeal the decision.