MONCTON, N.B.—A Moncton man who robbed a sandwich shop was caught when he unfriended the victim on Facebook shortly after the heist.

Prosecutor Jessica Lavoie said 20-year-old Ryley Smith was sentenced Wednesday to three years in prison for robbery and masking his face during the commission of a crime.

Smith admitted threatening a Subway employee with a knife and getting away with about $1,000 in cash on Nov. 12, 2014.

Lavoie said Thursday that the victim soon noticed Smith had unfriended him on the social media site, which got him thinking that perhaps Smith was the masked robber.

Lavoie said the victim went to police, who obtained a warrant for a DNA sample, and matched it to a bandana found in the Subway parking lot after the robbery.

Smith was arrested last November in Calgary, where he was then living.

Judge Irwin Lampert’s sentence was for three-and-a-half years, including the equivalent of six months for time served since his arrest.

Read more about: