CROWN POINT, Ind. (CBS) — A man is out of jail, after pleading guilty, but mentally ill, to molesting two young boys in Northwest Indiana, and being sentenced to time served.

Dewayne Scott Thomas, 42, of Chicago, admitted to molesting the young boys between July 1997 and December 2000 in Hammond, Ind. He was alone with the children at the time.

At a hearing Monday, Lake County, Ind., Superior Court Judge Diane Ross Boswell sentenced Thomas to the maximum of eight years in prison. But because he has already served more time than that in custody when factoring in time off for good behavior, Thomas was released after the sentence was imposed.

In total, Thomas had served 1,992 days – or nearly five and a half years – in custody.

Defense attorney Casey McCloskey said Thomas has been diagnosed with schizophrenia. He was found incompetent to stand trial and was sent to Logansport State Hospital in Logansport, Ind., for more than a year.

Lake County deputy prosecutor Reginald Marcus asked Judge Diane Boswell to impose the maximum sentence. “There was harm imposed to the children in this case and I urge the court to take that to heart,” Marcus said.

Thomas was first charged in September 2005 with two counts of child molesting, both Class A felonies punishable by a 20- to 50-year sentence.

The Post-Tribune contributed to this report, via the Sun-Times Media Wire