Earlier this month, the administration announced that insurers who lost money selling Obamacare would not get a $2.5 billion bailout—but it didn’t happen by chance.

Earlier this month, the administration announced that insurers who lost money selling Obamacare would not get a $2.5 billion bailout. It was great news for taxpayers, but it didn’t happen by chance.

Both chambers of Congress worked very hard to make those savings possible. And lawmakers will have to continue working hard to keep bailouts like this from happening in the future.

Here’s how Congress did it this time. But first, some background.

Obamacare used generosity to overcome insurance companies’ objections to its excessive regulation. For starters, the law mandated that everyone buy their product. It created new subsidies to help people make those purchases. And it massively expanded Medicaid, which is largely administered by insurers.

The law also created two back-end bailout programs designed specifically to benefit insurers selling Obamacare plans in the individual market. Goody No. 1 was a reinsurance program that reimburses Obamacare plans for most of the expenses run up by people with high annual claims. Funded by a tax on everyone with non-Obamacare coverage, the reinsurance program shoveled nearly $8 billion to Obamacare insurers last year.

The second bailout provision was a “risk corridor” program designed to collect payments from insurers who made excess profits–as determined by the federal government–and make payments to insurers with excess losses. If the government didn’t collect enough from profitable insurers to cover the compensatory payments, taxpayers would be stuck with covering the “shortfall.”

The design amounted to a double bailout, with taxpayers on the hook for subsidizing insurance company losses on the back-end as well as for the front-end subsidies and mandates that benefitted insurers.

The Democratic leadership was able to bulldoze Obamacare through Congress. But many lawmakers felt this sweetheart deal for insurers was a raw deal for taxpayers. In 2014, they decided to look into it.

The House Committee on Oversight and Government Reform scheduled a Feb. 5 hearing entitled “Obamacare: Why the Need for an Insurance Company Bailout?” The day before that hearing, the Congressional Budget Office released a study estimating that risk corridors would make the government $8 billion. Democrats gleefully trumpeted the projection at the hearing, with the Committee’s ranking member claiming that “billions of dollars in savings would simply disappear” if the risk corridors were eliminated.

But committee Republicans were skeptical. CBO’s assumption seemed inconsistent with anecdotal evidence that insurers were enrolling a disproportionately older, sicker population in Obamacare plans. To get a clearer picture of what was happening, the Oversight Committee began soliciting information from insurers themselves. Their investigation confirmed that enrollees were generally older and sicker than anticipated—and that insurers expected to net about $1 billion from risk corridor payments that spring.

The Committee released its preliminary findings at a June hearing. During that meeting, Jeff Sessions, (R-Ala.), then the ranking member of the Senate Budget Committee, raised a new issue: the questionable legality of the administration’s plan to transfer taxpayer funds to insurers through the risk corridor program.

In January, Sessions’ committee and the House Energy and Commerce Committee had identified that the Department of Health and Human Services (HHS) lacked an appropriation for bailing out insurance companies through the risk corridors. They asked the Government Accountability Office to look into the matter. That September, GAO issued its legal opinion: the administration would need an appropriation from Congress to make outgoing payments.

Of course, once insurers realized the risk corridor payments might be limited to whatever was collected from companies offering profitable plans, their lobbyists descended in droves, arguing that premiums would skyrocket unless lawmakers propped up insurers by letting taxpayer dollars flow through the risk corridors.

Fortunately, Congress rejected this bullying and decided that taxpayers should not be forced to bail out insurers that lost money on Obamacare plans. On Dec. 2, 2014, the Senate Republican Policy Committee issued a paper entitled “Ending Obamacare’s Insurance Company Bailout.” Shortly thereafter, Congress made the risk corridor program budget neutral for fiscal year 2015.

Now we know exactly how much that decision saved taxpayers this year: $2.5 billion. But what about FY 2016 and beyond? Congress will need to buckle down again—and either repeal the risk corridors entirely, or maintain budget neutrality until the program ends.

The Senate Budget Committee’s Director of Income Security from 2011-2015, Paul Winfree is now Director of the Thomas A. Roe Institute for Economic Policy Studies at The Heritage Foundation.