A Canadian who attacked a man he believed to be a zombie was found not guilty of murder by reason of insanity in a Scottish court on Wednesday.

BBC News reports that 19-year-old Tianhui Zhan was walking down the street in Glasgow, Scotland last October when he spotted 21-year-old Michael Davis.

Davis, who worked as a cleaner, was on his cell phone and en route between jobs at the time he was attacked. Zhan believed Davis was a zombie, and fatally stabbed the man three times.

The two men were not acquainted, and the victim had been randomly targeted.

The High Court in Glasgow learned that Zhan had a history of mental problems. Zhan had been diagnosed in Canada with bipolar disorder with a psychotic feature, the BBC reported.

He had stopped taking his anti-psychotic medication when he killed Davis, and he later told a forensic psychiatrist that he saw blood on peoples' faces.

The jury learned that Zhan, who was born in China and lived in Toronto, left Canada last September to travel across Europe. He said that 'voices' had urged him to go to Glasgow.

Judge Michael O'Grady informed the jury that expert witnesses thought Zhan was insane at the time of the attack. The jury unanimously returned the verdict — not guilty by reason of insanity — without retiring, according to the BBC.

The judge has ordered Zhan to be held in a state hospital.