PORTLAND, Ore. (AP) – A federal judge has ruled that Oregon no longer needs extra oversight to ensure criminal defendants in need of mental health treatment get to the Oregon State Hospital within seven days.

The Oregonian/OregonLive reports the development means the Oregon Health Authority is back in compliance with a 2002 court order that set the deadline.

The state hospital in Salem struggled between October 2018 and July to find beds for criminal defendants. People stayed in jails longer than the maximum seven days allowed because the state hospital didn’t have enough space.

Defendants who have a mental illness get treatment at the hospital so that they can understand the charges against them and make choices in their own best interests.

The newspaper investigated the crisis earlier this year, finding that defendants charged with misdemeanors were sometimes kept in jail far longer than even the maximum penalty for the charges they faced if convicted.

Disability Rights Oregon brought the backlog to the court’s attention in May, asking the judge to find Oregon in contempt of court for failing to meet the 2002 injunction. The judge denied the request but gave health officials 90 days to show they could fix the backlog.

The state made sufficient progress, according to the court order.