Updated

A 21-year-old gunman who disguised himself as a student to get into a New Mexico high school where he killed two students had caught the attention of U.S. investigators more than a year ago, authorities said Friday.

William Atchison, a former student at small-town Aztec High School, had legally purchased a handgun at a local store a month ago and planned the attack, authorities said. He left a message on a thumb drive found on his body that detailed his plan to wait until the students got off buses and made their way to class.

He mingled with students, then walked into school with them and went into a second-floor bathroom to "gear up." Atchison's plan was to shoot up a classroom and then kill himself.

"Work sucks, school sucks, life sucks. I just want out of this (expletive)," he wrote.

More lives could have been lost had Francisco I. Fernandez not walked into the bathroom, authorities said. The gunman shot Fernandez, then walked out into the hallway and encountered the second victim, Casey J. Marquez. He immediately killed her.

Atchison then walked up and down the hall, firing randomly, before killing himself, authorities said.

"He was determined to create as much carnage as he possibly could," San Juan County Sheriff Ken Christesen said.

The shooter did not have a criminal record, much less a traffic ticket, officials said. The only contact with law enforcement was what they described as a generic message on an online gaming forum in 2016 in which he talked about what weapons might be used in a mass shooting.

The FBI said the posting was flagged and investigators talked with the gunman at his home in Aztec, where he lived with his parents. At the time, he did not own any weapons other than an airsoft pellet gun and said he had no plans for an attack and just liked to troll sites online.

The shooting has rocked Aztec, a community of about 6,500 near the Colorado border. Hundreds gathered for prayer services and candlelight vigils and more gatherings are planned over the weekend as residents look for answers.

In one bright spot, authorities said heroes at the school helped save lives.

A substitute teacher heard the gunshots but didn't have a key to lock the door to the computer lab. So she took students into an office or storage area and barricaded the door with a couch.

Atchison came to the room and yelled that he knew they were in there and fired multiple shots into the room, authorities said.

A custodian also heard the gunshots and yelled for teachers to lock their doors.

State Police Chief Pete Kassetas said the two victims were not specific targets.

Marquez was a cheerleader and was planning to perform in the upcoming Orange Bowl. Her classmates said she came across as a student leader.

Bryn Divine, a senior at Aztec High School, remembered the victim being a vibrant and friendly student who often won dance contests at school events.

"She lit up pretty much any room we were all in," Divine said. "She was such a fun person to be around."

Fernandez was known for his interest in computers and his speed on the keyboard. His family has said he had a bright future ahead of him.

Gov. Susana Martinez said she has met with the teens' families and they talked about what great kids they were. Both of them also had jobs.

Martinez said the families are broken but are pulling together.

"I don't think anyone ever gets over this," she said.

Investigators were still combing over evidence at the school Friday, trying to determine how many shots were fired. The gunman had several magazines and reloaded multiple times, Kassetas said.

At Atchison's home, investigators found a torn note in a trash can in his room that listed what they believed to be the timeline for Thursday's shooting. The last words written on the note read "die."

Authorities don't believe anyone else knew about Atchison's intentions but said they are still investigating.

___

Associated Press writers Mary Hudetz and Susan Montoya Bryan contributed to this report from Albuquerque.