A new study finds syringe exchange programs in Philadelphia and Baltimore have prevented thousands of new HIV cases in people who use drugs. The programs also saved hundreds of millions of dollars in public health costs, the study found.

Researchers analyzed data from Philadelphia between 1984 and 2015, and data from Baltimore between 1985 and 2013, according to U.S. News & World Report. They looked for HIV diagnoses related to injection drug use to measure the impact of syringe exchange programs in those cities. Philadelphia authorized the programs in 1992, while Baltimore allowed them starting in 1994.

The study used a computer model to estimate the number of new drug-related HIV diagnoses in 10-year periods following the establishment of syringe exchange programs in both cities. They compared those estimates with actual reported diagnoses. They found that more than 10,500 HIV diagnoses related to injection drug use were prevented in Philadelphia between 1993 and 2002, and almost 2,000 were prevented in Baltimore from 1995 to 2004.