A Third District Court judge on Monday sentenced a man who robbed a Park City bank in February to five years to life in prison but committed him to the state mental hospital instead of sending him to prison.

Cody McCormick, who is 28 years old and from Kamas, will remain imprisoned at the Summit County Jail until there is space available at the Utah State Hospital. McCormick in April pleaded guilty to robbing the Key Bank branch on Snow Creek Drive on Feb. 25. In his plea, he acknowledged he was mentally ill at the time of the robbery.

In court papers filed against McCormick, prosecutors said he handed a teller an envelope with a handwritten note instructing the teller to fill the envelope with large-denomination bills. Prosecutors said the note said he would pull a knife if the instructions were not followed.

The teller put approximately $3,600 in $100 bills inside the envelope and gave it back to McCormick, who fled from the bank with the money, the prosecutors said. He was captured approximately three hours after the robbery after an area law enforcement officer recognized him from an image taken by a surveillance camera at the bank.

The authorities found the money and the envelope that held the handwritten note in his vehicle when he was arrested. They found a steak knife in the vehicle as well, the prosecutors said.

Prosecutors and his public defender have indicated McCormick has suffered mental health issues for years.

“This is kind of the best situation for everyone involved,” Joy Natale, the Summit County prosecutor on the case, said about the commitment to the hospital, indicating McCormick will receive treatment while he is incarcerated.

Paul Quinlan, the public defender assigned to McCormick, said McCormick will undergo evaluations at the state mental hospital. He said he anticipated McCormick would be sent to the state facility. When the people treating him there determine he has made enough progress, he could be released and put on probation, Quinlan said.

Bank robberies in Park City are rare, and the authorities swarmed to the bank after receiving the report. The police and FBI agents arrested McCormick on lower Iron Horse Drive, in the common area of a commercial building, the police said at the time.