YILAN, Taiwan (Reuters) - The driver of a train in Taiwan that crashed killing 18 people told a court on Tuesday he had switched off its speed-control system, a court official said, as investigators pieced together events that led to the island’s worst rail crash in decades.

An overturned train is seen in Yilan, Taiwan October 22, 2018. REUTERS/Yimou Lee

The train came off the rails on Sunday on a curve while moving at almost 87 miles per hour (140 kmh), nearly twice the speed limit of 46 mph (74 kmh), in the island’s mountainous northeast, the head of a government investigation team said.

Chief investigator Wu Ze-cheng told Reuters earlier it was not clear whether the speed-control system, called automatic train protection, had switched off by itself or had been manually disabled before the accident, which also injured 187 people.

A spokesman for Taiwan Yilan District Court told Reuters the driver told his bail hearing he switched off the system himself to boost the train’s power when it had slowed down on an earlier stretch of the journey.

“He should have turned the system back on at the next stop,” said the court spokesman, Huang Yong-sheng.

“The defendant is highly suspected to have been negligent.”

Reuters was not able to reach the train driver, You Zhen-zhong, 48, for comment. He was granted bail of T$500,000 ($16,167) and barred from leaving Taiwan after being detained for the investigation.

You had been treated in hospital after the accident.

You’s public defender, Kou Tua-jai, said the driver knew he had to turn the protection system back on, but he had failed to do so because he was busy communicating with other coordinators due to a separate problem with the train’s speed.

“He admitted that he’s responsible for dereliction of duty, but he’d like to raise one point: there was something wrong with the train,” Kou told Reuters.

Kou said the driver said the speed shown on the train’s indicator was not its real speed.

Chief investigator Wu said more investigation was needed to determine why the driver failed to turn the protection system back on.

He said it was not immediately clear if the speed shown on the train’s indicator was different to its actual speed.