ST. PAUL, Minn. (WCCO) — Minnesota Gov. Mark Dayton said Wednesday the state will appeal a federal court ruling declaring the state’s sex offender program unconstitutional.

In his first public comments since last week’s stinging rebuke of the program, the governor said he plans to personally appear at a federal court hearing in August to discuss it.

READ MORE: 'This Cannot Continue': Minnesota Leaders React To Deadly Texas School Shooting

A federal judge last week denounced Minnesota’s sex offender program for locking up sex offenders indefinitely — even after serving time for their sex crimes.

Dayton says the state will appeal that ruling, for the safety of the public.

“They want to make sure their government is doing absolutely everything conceivably possible to make it 100 percent safe,” said Dayton, a Democrat, “to walk in a park or to or from school or wherever else they go.”

Federal Judge Donovan Frank ruled last week that Minnesota’s sex offender “treatment” is no treatment at all. In 20 years, no one has been unconditionally released.

“The Constitution protects individual rights even when they are unpopular,” Frank wrote.

But Dayton says the state has other concerns, such as where to place hundreds of sex offenders around the state, and how to pay for it.

READ MORE: Royce Lewis 'Couldn't Be Happier' About Time With Twins

“The ruling makes drastic changes in terms of the program, in terms of facilities, in terms of costs,” the governor said. “It’s one that we don’t take lightly and I think that needs an appellate review.”

Dayton says he will personally attend a federal court hearing in August to discuss the program, even if he has to postpone a major trade mission to Mexico the same week.

And while he’s open to ideas to change the program, Dayton said he believes it is constitutional.

“The idea of taking people and releasing them into society after their prison sentence has been completed is not a viable option in my view,” Dayton said.

Dan Gustafson, a lawyer representing some of the sex offenders confined in treatment centers, is questioning the wisdom of the appeal.

Gustafson said an appeal could keep sex offenders confined for another two years.

MORE NEWS: 3 Years After Fire, Construction Begins On Lake Bde Maka Ska Pavilion

“It’s time to start fixing the problem and not delaying the decision any longer,” he said.