The Department of Health and Human Services has four years to end an estimated 700,000 Medicare appeal backlog, a court ruled.

An order from the U.S. District Court for the District of Columbia hews closely to a timeline suggested by the American Hospital Association. The association filed suit against HHS over its “highly backlogged” process.

Previously, the same judge ruled that clearing the backlog would be “extremely wishful thinking.” He changed course after reading briefs from both parties.

HHS must achieve a 30% reduction by the end of 2017 and in each of the next two years. It could face further court action if it fails to meet the deadlines.

“Satisfying the statutory demands for both accuracy and timeliness will no doubt prove challenging, but such is the task at hand,” Judge James E. Boasberg wrote in his ruling.