Police say the man charged with fatally shooting two students and wounding four others in a North Carolina university classroom told them he’d planned the shooting for months but gave up the assault after he was tackled and brought to the floor.

Police detectives say in newly unsealed search warrants that former student Trystan Andrew Terrell admitted entering the University of North Carolina at Charlotte on April 30 intending to shoot people. The warrants say he paused to load his gun in a bathroom before attacking. A student was fatally shot when he tackled the shooter.

In statements seeking court permission to access the suspect’s cellphone, a police detective described Terrell as saying he used his phone to record a video of the area where the shooting happened. It’s not clear what the recording shows.