A case of mistaken identity landed a man in a mental institution for nearly three years.

According to the Associated Press, Joshua Spriestersbach was falsely arrested in 2017 after he fell asleep outside a Honolulu homeless shelter. The now-50-year-old man said he was assumed he was being arrested for violating the city’s ban on sleeping on public sidewalks; however, it turns out the officer had misidentified Spriestersbach as Thomas Castleberry—a fugitive who had an outstanding probation warrant stemming from a 2006 drug case.

The Hawaii Innocence Project, a nonprofit that supports the wrongfully convicted, filed a petition Monday asking the court to vacate Spriestersbach’s arrest. The organization said it is unclear how the officer mistook Spriestersbach for Castleberry, as the two men never met and there is no indication that Spriestersbach ever identified himself as the wanted man. Though he allegedly told officers they had arrested the wrong guy, he was ultimately committed to the Hawaii State Hospital, where he remained for two years and eight months.

“The more Mr. Spriestersbach vocalized his innocence by asserting that he is not Mr. Castleberry, the more he was declared delusional and psychotic by the H.S.H. staff and doctors and heavily medicated,” the petition read. “It was understandable that Mr. Spriestersbach was in an agitated state when he was being wrongfully incarcerated for Mr. Castleberry’s crime and despite his continual denial of being Mr. Castleberry and providing all of his relevant identification and places where he was located during Mr. Castleberry’s court appearances, no one would believe him or take any meaningful steps to verify his identity and determine that what Mr. Spriestersbach was telling the truth — he was not Mr. Castleberry.”