A man convicted of child molestation was able to walk free for nearly a month after he was erroneously released from a Louisiana prison.

The mistake was chalked up to a mathematical error.

According to arrest records, 66-year-old Brian Matherne still had seven years left on his nearly 30-year sentence when he was freed from Rayburn Correctional Center in Washington Parish on February 1.

He pleaded guilty to charges of molestation of a juvenile and aggravated crimes against nature back in 2000.

Matherne was supposed to serve out his entire sentence without the possibility of an early release. Department of Corrections officials didn't catch the "erroneous time calculation" mishap until February 27 when a prosecutor and a state lawmaker familiar with the case brought it to the agency's attention.

"Brian Matherne was originally released based upon the application of general good time provisions, however, DOC obtained the original court transcripts and confirmed that the court specifically restricted the application of good time to the sentence imposed," the Department of Corrections said.

Officials say that Matherne was taken back into custody late on Wednesday, March 2, and booked back into Rayburn Correctional Center.

10 of Louisiana's Weirdest Laws

More From 99.9 KTDY