Want the best of VICE News straight to your inbox? Sign up here.

A homeless man in Oklahoma City was sentenced to 15 years in prison after pleading guilty to cocaine possession charges. The problem is, he was only carrying powdered milk from a nearby food pantry.

Cody Gregg apparently entered a guilty plea just so he could leave the Oklahoma County jail where he was held on a $50,000 bond, according to the Oklahoman. (He didn’t cite a specific reason, but the jail has faced lawsuits over mold exposure and inmate deaths and has been plagued by issues of overcrowding.)

But then, the court received the results of a lab report, which revealed the substance police found on Gregg wasn’t cocaine — it was powdered milk. After that, Gregg asked to withdraw his guilty plea, and his case was dismissed. He was released from jail Friday.

Gregg was riding his bike shirtless through downtown Oklahoma City around 10:30 p.m. on Aug. 12 when police tried to stop him for failing to have rear lights. Police said Gregg pedaled away, and then began running on foot, which gave them a reason to search his belongings when they finally stopped him. That’s when the officers found a plastic baggie of white powder, which they believed was cocaine. Police said the substance also tested positive for cocaine based on a quick field test.

At the time of his Aug. 12 arrest, Gregg was on probation for another drug charge he pleaded guilty to in 2017, according to court records. He had also previously pleaded guilty to drug possession charges relating to marijuana and meth.

Gregg’s arrest isn’t the first time that cops have mistaken an otherwise innocent substance for drugs based solely on its appearance. In 2015, for example, a 64-year-old man was pulled over and searched by Orlando police, who noticed some white crystals on the floor of his vehicle. Those crystals, based on a quick field test, were from methamphetamine.

The man was subsequently arrested — until cops realized the crystals were actually from a doughnut glaze. (The man filed a lawsuit against the city and was awarded $37,500.) In 2017, another Florida man was jailed for months after police mistook drywall dust in his car for cocaine.