An Alabama man sentenced to life in prison without parole for a $50 robbery has been granted an early release after spending the past 36 years behind bars.

According to court docs, in 1979, when Alvin Kennard was just 18 years old, he pled guilty to three counts of second-degree burglary in connection with a break-in at an unoccupied service station and was sentenced to three years’ probation.

On January 24th, 1983, Kennard used a pocket knife to rob a bakery, and ended up making off with $50.75 from the business. After being convicted of first-degree robbery, he was sentenced to life in prison without the possibility of parole.

Because the bakery robbery incident was Kennard’s fourth offense, an Alabama state law at the time stated that the judge had no other option than to sentence him to life in prison.

The law, called the Habitual Felony Offender Had, has since been changed and allows judges to give repeat offenders the possibility of parole, however, when the law changed in the early 2000s it didn’t apply to cases before then, including Kennard’s.

Thanks to the curiosity of Circuit Judge David Carpenter, Kennard—who is now 58 years old—was able to be re-sentenced and now, after being credited for time served, he’s scheduled to be released from the William E. Donaldson Correctional Facility in Bessemer within the next few days

At his hearing Wednesday, Kennard’s attorney, Carla Crowder, argued that under Alabama’s current sentencing guidelines, he would have received 10-20 years in prison instead of life without parole.

“Even if under today’s Habitual Offender Act, if that was invoked in this case, he’d be eligible for a sentence up to life,” Crowder told the judge.

Crowder went on to make the case for Kennard’s release, highlighting that he’s currently residing in the prison’s honor dormitory and hasn’t had a disciplinary infraction in more than 10 years.

Crowder also pointed out that Kennard had over a dozen friends and family members who were present in the courtroom for his re-sentencing, and that “he has maintained family ties, and he’s got a niece that had regularly visited him. He’s got a home to come back to.”

She added, also speaking on behalf of his family: “We have no doubt that he would do well on the outside. When we spoke this morning, he brought up that he just wants to work. I think that is commendable.”

Before Judge Carpenter announced his decision to grant him time served and order his near-immediate release from prison, Kennard apologized for what he had done in the past.

“I just want to say I’m sorry for what I did,” Kennard said. “I take responsibility for what I did in the past. I want the opportunity to get it right.”

Carpenter replied: “It means a lot for me that you are taking responsibility for what you have done.”

Kennard said upon release, he plans to live with relatives in Bessemer and hopes to find work as a carpenter.

His niece, Patricia Jones, was happy about her uncle’s release and said she knows he’s a changed man.

“God is just showing his power,” Jones—who who said she’s been visiting Kennard in prison for as long as she can remember—told CBS 42.