The city of Flint, Michigan, has a plan to replace around 18,000 underground water pipes thanks to an agreement with the state.
A judge approved the settlement Tuesday. It gives the state until 2020 to replace Flint's ailing water system.
Michigan will pay $87 million for the project. About a third of that money will come from aid the U.S. Congress approved last year. The state will keep another $10 million in reserve for costs that exceed expectations.
Flint residents started complaining about their water two years ago when the source of their water changed from Lake Huron to the Flint River.
Water from the lake was treated with anti-corrosion chemicals to protect the pipes. The river water was naturally more corrosive and wasn't properly treated, so lead and other harmful substances leaked into the water.
Beyond replacing the pipes, the agreement requires the state to continue providing free bottled water until at least April of this year and to continue door-to-door water filter checks through December 2018.