CNN  — 

A man pleaded guilty to cocaine possession in Oklahoma – only to withdraw his plea and have his case dismissed after it turned out to be powdered milk.

Cody Gregg was sentenced to 15 years in prison last week after he pleaded guilty to possession of cocaine with intent to distribute, according to court records. His guilty plea was the result of an August arrest and charge of trafficking illegal drugs.

After a lab report showed a negative test for drugs, he withdrew his plea, court records show. On Thursday, an Oklahoma County judge approved the request, leading to a dismissal the next day, according to The Oklahoman.

Gregg, 26, told the judge that the powered milk was from a food pantry, according to the paper. It said he was riding his bike on August 12 when an officer tried to stop him because he had no rear lights. He pedaled faster then jumped off his bike and fled, and officers found the white powder in his backpack, the paper said, citing an affidavit.

He was released Friday after being in jail since his arrest in August, the paper said.