KAMPALA, April 30 (Reuters) – A Ugandan court sentenced a man to death on Thursday for killing four young children ‌this month at a nursery school, in an attack ‌that sparked public outrage and concern for pupils’ safety in the East African ​country.

The judge said an investigation of Christopher Okello Onyum’s phone and laptop had found searches including “schools near me” and “ISIS beheading”, a reference to the Islamic State group.

In the attack, which took place on ‌April 2 at a ⁠nursery school in the capital Kampala, 39-year-old Onyum stabbed his four victims – toddlers aged two and three ⁠years old – before a guard subdued him, police said.

Angry parents tried to lynch him before he was detained.

Onyum had pleaded not guilty ​to ​murder, and one of his lawyers ​had argued that he ‌should be acquitted because he had long been mentally unstable and had been committed to a psychiatric hospital.

“I have no doubt in my mind that the search for ‘ISIS beheading’ prepared the accused person to launch this fatal attack,” Judge Alice Komuhangi Khaukha said ‌while delivering the sentence.

She rejected his ​lawyer’s assertion that Onyum was insane, saying ​that his attack, which ​took less than seven minutes, had been carefully ‌planned.

Onyum was seen laughing in ​the dock during ​his trial, which his lawyer said showed he was mentally ill.

Although Uganda still hands down the death penalty for serious ​offences such as ‌murder, the last execution was carried out roughly two decades ​ago.

(Reporting by Vincent Mumo Nzilani and Elias Biryabarema;Editing by ​Alexander Winning and Gareth Jones)