ST. PAUL, Minn. (AP) —A federal judge has ordered a risk assessment of all sex offenders in Minnesota's restrictive civil confinement program to determine which can be put on a pathway for release.

Judge Donovan Frank on Thursday laid out what he says must be done to fix problems with indefinite detentions that he earlier ruled unconstitutional. Frank's decision undoubtedly sets the stage for an appeal by state officials and lawyers, who argue they are properly holding more than 700 offenders they consider too risky to free.

Frank's ruling sets a swift timetable for state officials to carry out the review and start transferring lower-risk offenders. He says he could order further changes later.

Offenders in a pair of secure treatment facilities are sent there after they complete their criminal punishments.

The attorney for sex offenders who successfully sued over its civil commitment program says it's unclear when evaluations of patients will commence.Dan Gustafson said Thursday that his clients are pleased but "frustrated with the slow pace" of the court proceedings. An appeal by the state could drag that out further.

Gustafson says the court will help determine a timeline for the evaluations. He says there are clearly some residents who no longer fit the criteria to be held at the two facilities but declined to guess how many.