A Colorado judge has accepted Aurora theater shooting suspect James Holmes’ plea of not guilty by reason of insanity.

According to The Associated Press, by accepting the plea, the judge has set up a lengthy psychological evaluation of Holmes, who is suspected of killing 12 people and injuring 70 others during the shooting at a midnight screening of The Dark Knight Rises on July 20. Among those killed were a 6-year-old girl and a Navy veteran who sacrificed himself to save his friends.

He has been charged with 166 counts that include murder and attempted murder, notes ABC News.

Prosecutors believe that Holmes had planned out the entire shooting, as evidenced by the fact that he wore armor to the theater and had spent months buying weapons before the shooting. The police say that he had used a gas grenade before he opened fire.

The insanity plea is seen as the 25-year-old’s best way to avoid a death penalty sentence. With the insanity plea accepted, Holmes will not be put through a state psychological test, which is expected to take months.

If a jury says he is not guilty by reason of insanity, he’d be confined to a mental hospital likely for the rest of his life. But if he’s convicted, there will then be testimony for and against the death penalty.

Holmes was at the hearing, still wearing a beard but with a less disheveled look than past hearings. ABC News notes that he appeared as if he did understand the proceedings, reading along and telling the judge that he had no questions.