A man charged with a felony after a police officer found a methamphetamine pipe in his pocket entered a guilty plea Thursday in Albany County District Court.

Frederick Harnden, 37, pleaded guilty on one count of possession of a controlled substance, third or subsequent offense. If sentenced at the maximum, he could spend five years in prison and pay a $5,000 fine.

As part of the plea deal, prosecutors agreed to dismiss charges stemming from crimes Harnden allegedly committed while out on bond. Prosecutors will make no recommendation as to Harnden's sentence.

Harnden was arrested May 14 after an officer of the Laramie Police Department responded to a residence on Laramie's west side for a report of a possible domestic dispute in progress.

The officer found Harnden, who officers sought in connection with the possible domestic dispute, walking in the 100 block of Colorado Avenue. Harnden was arrested on a county warrant for failure to pay.

The officer handcuffed Harnden and asked if he had any weapons or drugs on his person. Harnden allegedly said he had a methamphetamine pipe in his pocket.

A search of Harnden's person reportedly turned up a pipe with methamphetamine residue inside as well as two small plastic bags with powder residue inside. That residue tested presumptively positive for methamphetamine, according to the affidavit.

Court documents say Harnden was previously convicted on possession charges in 2011 and 2013.

Harnden said in court Thursday that he had followed Judge Jeffrey Donnell's previous advice to choose his family over drugs.

"I was about to get to see my kid again," Harnden said. "I gave up the drugs. The other stuff was just stuff I had previously."

Defense attorney Randy Hiller asked that Harnden's signature bond be continued so that he could continue his progress with the Department of Family Services, but Donnell remanded Harnden to custody pending sentencing.

Donnell said "Mr. Harnden has a long history with this court," and added that if Harnden were to have any more trouble while out on bond, he would certainly be looking at prison time.

"Believe it or not, this is for your own good," Donnell concluded.