BALASORE, India (AP) — The derailment in eastern India that killed more than 300 people and injured hundreds was caused by an error in the electronic signaling system that led a train to wrongly change tracks and crash into a freight train, officials said Sunday.

Authorities worked to clear the mangled wreckage of the two passenger trains that derailed Friday night in Balasore district in Odisha state in one of the country’s deadliest rail disasters in decades.

Jaya Verma Sinha, a senior railway official, said the preliminary investigations revealed that a signal was given to the high-speed Coromandel Express to run on the main track line, but the signal later changed, and the train instead entered an adjacent loop line where it rammed into a freight loaded with iron ore. The collision flipped Coromandel Express’s coaches onto another track, causing the incoming Yesvantpur-Howrah Express from the opposite side also to derail, she said.

The passenger trains, carrying 2,296 people, were not overspeeding, she said. Trains that carry goods are often parked on an adjacent loop line on the side so the main line is clear for a passing train.

Verma said the root cause of the crash was related to an error in the electronic signaling system. She said a detailed investigation will reveal whether the error was human or technical.

The electronic interlocking system is a safety mechanism designed to prevent conflicting movements between trains. It also monitors the status of signals that tell drivers how close they are to a next train, how fast they can go and the presence of stationary trains on the track.

“The system is 99.9% error free. But 0.1% chances are always there for an error,” Verma said. To a question whether the crash could be a case of sabotage, she said "nothing is ruled out.”

On Sunday, a few shattered carriages, mangled and overturned, were the only remnants of the tragedy. Railway workers toiled under the sun’s glare to lay down blocks of cement to fix the broken tracks. A crew with excavators was removing mud and the debris to clear the crash site.

Fifteen bodies were recovered on Saturday evening and efforts continued overnight with heavy cranes being used to remove an engine that settled on top of a rail car. No bodies were found in the engine and the work was completed on Sunday morning, said Sudhanshu Sarangi, director-general of fire and emergency services in Odisha.

The crash occurred at a time when Prime Minister Narendra Modi is focusing on the modernization of the British colonial-era railroad network in India, which has become the world’s most populous country with 1.42 billion people. Despite government efforts to improve safety, several hundred accidents occur every year on India’s railways, the largest train network under one management in the world.

Modi visited the crash site on Saturday and talked to rescue officials. He also visited a hospital to inquire about the injured, and spoke to some of them.

Modi told reporters he felt the pain of the crash victims. He said the government would do its utmost to help them and strictly punish anyone found responsible.

In 1995, two trains collided near New Delhi, killing 358 people in one of the worst rail accidents in India. In 2016, a passenger train slid off the tracks between the cities of Indore and Patna, killing 146 people.

Most such accidents in India are blamed on human error or outdated signaling equipment.

About 22 million people ride 14,000 trains across India every day, traveling on 64,000 kilometers (40,000 miles) of track.

___

Saaliq and Sharma reported from New Delhi.