A man accused of killing two students and wounding four more by opening fire in a North Carolina university classroom earlier this year pleaded guilty to two first-degree murder charges on Thursday.

Trystan Andrew Terrell also pleaded guilty to four counts of attempted murder and discharge of a firearm on educational property in connection with the April 30 shooting at the University of North Carolina at Charlotte. The hearing was originally intended to decide whether Terrell could face the death penalty.

Prosecutors believe Terrell, a former student at the school, spent months planning the attack. Authorities say he opened fire with a legally purchased pistol on the last day of spring semester classes. It wasn’t clear if a specific student was targeted.