SALEM, Mass. — A Haverhill man was sentenced to three to four years in state prison Tuesday after pleading guilty to an armed robbery at a Haverhill convenience store last fall. 

Joseph Lee Foster, 31, was charged after both Haverhill police and the grandparent of Foster’s child recognized him from surveillance images from the Red Hen convenience store on River Street. 

The grandparent contacted police after seeing Foster’s image in a video shared with the media. 

The holdup occurred on Nov. 28, when Foster walked into the store and initially appeared to be there to purchase a lottery ticket and a candy bar. But he pulled up a piece of clothing over his face and demanded cash, eventually going behind the counter to get it. 

On his way out, he dropped a knife in the store. Police also found a piece of clothing outside that fit the description of what the robber was wearing. 

Police later released a surveillance video from the store. 

“I just realize I messed up,” Fowler told Salem Superior Court Judge Salim Tabit Tuesday during his hearing. “I’m thankful we can resolve this.” 

Under the plea agreement reached between prosecutor Susan Dolhun and defense attorney Joseph Gannon, the original charge of armed robbery while masked, which carries a five-year mandatory minimum was reduced to armed robbery.