An Air Force Academy cadet was sentenced to three years in prison on Wednesday after pleading pleaded guilty to illegally using, distributing and bringing on to a military base several drugs, including Molly, and was sentenced to three years in prison on Wednesday.

Cadet 3rd Class Nathaniel L. Penalosa was accused of using LSD, methylenedioxy-methamphetamine — commonly known as MDMA, ecstasy or Molly — and the stimulant Modafinil several times between August 2014 and November 2014. Penalosa also was charged with allegedly bringing the drugs them onto academy grounds and distributing them on multiple occasions, and he was accused of wrongfully manufacturing MDMA.

Penalosa pleaded guilty to all charges as part of a pretrial agreement, the academy said in a release. He will also be dismissed from the academy with the equivalent of a dishonorable discharge, and must forfeit all pay and allowances. As a cadet, Penalosa earned $1,027.20 per month. He was originally sentenced to 42 months confinement, but as part of his guilty plea agreement, his sentence was limited to three years.

The Colorado Springs Gazette reported that three cadets, who were granted immunity in the case, testified at an August hearing that Penalosa sold them Modafinil, which helped them stay awake and study, and LSD. A random room inspection uncovered drug residue that turned out to be Molly and drug paraphernalia, the Gazette said.