An outbreak of Legionnaires’ disease that killed 12 people and sickened at least 87 in Flint, Mich., in 2014 and 2015 was caused by low chlorine levels in the municipal water system, scientists have confirmed. It’s the most detailed evidence yet linking the bacterial disease to the city’s broader water crisis.

In April 2014, Flint’s water source switched from Lake Huron to the Flint River. Almost immediately, residents noticed tap water was discolored and acrid-smelling. By 2015, scientists uncovered that the water was contaminated with lead and other heavy metals.

Just months after the water source changed, hospitals were reporting large numbers of people with Legionnaires’ disease.

The bug can enter the lungs through tiny droplets, like ones dispersed by an outdoor fountain or sprinkler system, or accidentally inhaled if a person chokes while drinking.

Although the outbreak of Legionnaires’ happened at the same time as the Flint water crisis, it was initially unclear how the two were connected.

The new studies also suggest that a complex set of factors may be responsible for low chlorine levels during the crisis. In addition to killing microbes, chlorine can react with heavy metals like lead and iron, and with organic matter from a river. That means lead and iron in the water may have decreased the amount of chlorine available to kill bacteria.

That also helps explain why the disease outbreak ended when the city switched back to its original water source, even though Legionella bacteria aren’t completely gone from the water system.