Two Iowa men will serve prison time after one of them accidentally pocket-dialed 911 while the other was making methamphetamine, deputies say.

According to KCRG, Cody Davis Brown was cooking meth in a building outside a Brandon home on Aug. 2, 2016, when guest Daniel David O'Hara's cellphone, which was in his pocket, somehow called 911, the Buchanan County Sheriff's Office said Tuesday. O'Hara then took the battery out of his phone after realizing the call had gone through, deputies said.

>> Read more trending news

Deputies responded, discovered Brown making the drug and arrested him, authorities said. O’Hara also was arrested and charged with possession of methamphetamine and zopiclone after deputies learned he was wanted in Wisconsin.

Brown was sentenced Tuesday to 20 years in prison after he was convicted of manufacturing and possessing meth. O'Hara was sentenced in October 2016 to five years in prison.