A Hanover man has admitted to killing his friend by stabbing him 17 times.

Matthew Kailing pleaded guilty Wednesday to second-degree murder in connection with the 2014 death of Rick Connor.

Court heard that Kailing, who was dealing with mental health issues and was not always taking his medication, was living with Connor while trying to get his life back together.

He was sentenced to life in custody, and will become eligible to apply for parole after 11 years.

His sentence will be served in a secure treatment facility, where he can receive help for his mental health issues.

At the time of Connor’s death, authorities in Hanover said it was the first murder in their community in more than 20 years.