TUSCALOOSA, Ala. (AP) — A judge on Monday sentenced a former Alabama sheriff to 18 months in federal prison after he pleaded guilty to scamming a food bank and his own small-town church to obtain inexpensive jail food and boost his personal income.

U.S. District Judge Liles Burke sentenced former Pickens County Sherriff David Abston to serve 18 months for wire fraud and filing a false tax return, federal prosecutors said in a news release. Abston was ordered to pay $51,000 in restitution.

Abston was sheriff for over 30 years until the accusations derailed his lengthy law enforcement career. He resigned and pleaded guilty to one count of wire fraud and one count of filing a false tax return.

Prosecutors said Abston in 2014 got the West Alabama Food Bank to agree to provide low-cost food to his own church, Highland Baptist of Gordo. The food bank agreed to provide food to help feed the poor, including poor children. Instead, much of the food went to the Pickens County Jail which Abston ran.

The arrangement helped Abston boost his personal income, prosecutors said, because a state law at the time allowed sheriffs to pocket excess jail food funds. Legislators have since changed the law.

“Abston tarnished his office and his badge,” U.S. Attorney Jay Town said in a statement. “He found out today he isn’t above the law. Those who believe they are will find themselves in federal prison.”

Abston’s attorneys had asked for a sentence of home confinement and community service, citing his remorse and long history of public service.

“While Sheriff Abston is deeply disappointed in today’s sentence, he has accepted responsibility for the wrong he committed and respects the court’s decision imposing consequences for his actions. He will serve his sentence, do what good he can during his period of incarceration, and then return to the community he loves to continue his life of community involvement,” Abston’s defense attorneys said in an emailed statement.