Medicare Part D is saving the government $12 billion per year by keeping seniors out of hospitals and nursing homes, according to a new study appearing in the Journal of the American Medical Association. The study’s authors say that in addition to the cost savings, seniors are being spared the discomfort and despair of being admitted to an institution and are instead enjoying a better quality life.

The study, conducted by researchers at Harvard Medical School, found that seniors who would have had insufficient drug coverage without Part D saved an average of $1,200 per year by being on the program. By providing seniors with drugs to control chronic conditions, such as diabetes and hypertension, doctors can cut down on trips to the emergency room, explained Michael McWilliams, who spearheaded the study.

“Spending on one type of service can reduce spending on another type of service,” McWilliams told the Associated Press. “By expanding Medicare to include drug benefits, clearly we’re spending more, but we’re getting a lot of value out of that spending.” For instance, doctors are no longer required to admit patients to the hospital just so that Medicare will pick up the cost of their drug treatments.

This new study reveals the complexity of the issue before lawmakers in Washington attempting to get a handle on the budget deficit. Cutting Medicare in one place may result in unintended increases in spending elsewhere in the program.

For more on Medicare Part D, see:

Part D costs dropping

Seniors caught between cancer and the cost of treatment

Medicare plans receive billions in overpayments