(CNN) A Wisconsin teenager accused of stabbing a classmate in 2014 to win favor with a fictional internet character named "Slenderman" has been ordered to spend 40 years in a mental institution instead of serving jail time.

Morgan Geyser, 15, pleaded guilty in October to a charge of attempted first-degree murder in a deal with prosecutors to avoid jail time.

Geyser's sentence was handed down after a day of testimony from expert witnesses about the teenager's progress in psychological treatment. While she has made progress, according to the experts, Waukesha County Circuit Judge Michael Bohren determined she needed further treatment.

"We can't forget what we are dealing with. And we can't forget that this was an attempted murder," Bohren said when announcing his decision. He also noted the crime was premeditated.

Geyser's defense attorneys had argued the teenager was a first-time offender who needs treatment but could be reintegrated into the community.