A former prison inmate has baffled authorities in New York City after being caught breaking back into two local jails in recent days pretending to be an inspector with a fake gold badge and papers.

Exactly what Matthew Matagrano, 36, thought he was doing might become clearer when he stands before a judge this Wednesday. He has already spent time behind bars for a sexual assault conviction and is a registered sex offender in New York. Wanting to get back inside is not generally considered normal behaviour for ex-cons.

A resident of Yonkers, a suburb just north of the city, Matagrano is accused of having broken into Rikers Island, the city’s largest detention facility which is adjacent to La Guardia Airport and houses 14,000 inmates and has a prison officer staff of 9,000. He is also accused of breaching the fortress-like Manhattan Detention Centre near the headquarters of the New York Police Department downtown.

Download the new Independent Premium app Sharing the full story, not just the headlines

According to a criminal complaint, he entered the Manhattan facility under false pretenses about 3.30pm last Thursday and began milling around with inmates, sharing cigarettes with some of them in the prison’s common area until 11pm when guards finally got wise to him after spotting him on surveillance cameras. The tapes also showed Matagrano rearranging inmates between cells and stealing a walkie-talkie from an office.

Aside from his conviction in 1996 of sexual abuse and sodomy – the case, according to court records, involved the rape of a 17-year-old boy – Matagrano also landed in trouble with the law in 2004 for impersonating a worker from the city’s Department of Education and breaking into a school where he spent time rifling through the files of students before he was caught. He pleaded guilty to attempted burglary at the time. He served one year behind bars for the rape and was sentenced to two to four years in the case of the school break-in.

The question this time for the courts may be a ticklish one. If Matagrano, who was released at the weekend on bail of $50,000, is found guilty of the charges so far filed against him which include burglary, possession of forged instruments, larceny and promoting prison contraband, how should he be punished? Putting him in jail may simply achieve the point of the crime in the first place.