TOPEKA, Kan. (AP) — A Kansas man who was forced to participate in the killing of his good friend to save his own life during a violent rampage in which two others died pleaded guilty to attempted second-degree murder.

Shane Andrew Mays, 22, also pleaded guilty Thursday to aggravated battery in the March 2017 attack in a Topeka drug home, WIBW-TV reported. Police said 19-year-old Matthew Leavitt, 38-year-old Nicole Fisher and 20-year-old Luke Davis were strangled or smothered to death over an unproven rape allegation against Leavitt.

Four others previously entered pleas, including Joseph Krahn, who was sentenced to three life terms.

Mays, who originally was charged with two counts of premeditated first-degree murder, and his friend, Leavitt, went to the home after being asked to give Fisher a ride. Two armed men ordered the two inside, where they and Fisher were zip-tied and threatened. Davis arrived at the house seeking a ride and was also restrained, Chief Deputy District Attorney Dan Dunbar said Thursday.

Mays was asked to help kill Fisher, Leavitt and Davis in exchange for his life, Dunbar said. Davis and Fisher were killed and Mays put a bag over Leavitt’s head and hit him repeatedly until another man strangled him. Mays then was allowed to leave and walked to the police station, where he reported the deaths.

During the preliminary hearing, witness Richard Folsom said Mays was told he had to take part in the killings to “dirty his hands.”

Defense attorney Kathleen Ambrosio described Mays during the hearing as a victim.

Mays will be sentenced on May 21.