The Social Security system is in trouble. It’s not just a future problem; America’s retirement insurance program is in trouble now. The federal government will start dipping into its Social Security savings account this year to help pay retirement benefits to millions of Americans.

In 2018, the federal government expects to receive about $2 billion less in payroll taxes and investment income than it will need to pay workers through the Old-Age, Survivors, and Disability Insurance program. If nothing changes, that savings account will run dry by 2034, right around when the last of the baby boomers reach retirement age. After that, the government will only have enough money to pay retirees and disabled workers 79 cents for every dollar they’re owed.

These findings were recently published in the Social Security Administration’s 2018 trustees report, prompting the expected torrent of alarming headlines, such as “Get Ready for the Great Depression” and “Social Security & Medicare are slowly dying, but no one in Washington will lift a finger.”

The annual report, prepared by government economists at the SSA, cited many reasons for the crisis, but it basically comes down to this: More Americans are retiring, and they are living longer. And there is no economic boom in sight.

But buried in the trustees’ report were a few calculations that point to a potential silver lining, though it’s one that the Trump administration probably doesn’t want to hear. Economic estimates show that immigration would help save the Social Security system. Not just legal immigration — illegal immigration too.

Undocumented immigrants and immigrants with legal status pay billions of dollars each year into the Social Security system through payroll taxes. Based on estimates in the trustees report, the more immigrants that come in, the longer the Social Security system will stay solvent. That’s because immigrants, on average, are a lot younger than the overall US population, so their retirement is far off. And undocumented immigrants pay for Social Security, but they’re not allowed to get benefits.

Here are two charts that show the impact of immigration on the Social Security system. The first chart shows how the Social Security Trust Fund (essentially a savings account) will run out of money if Congress doesn’t do something to boost its reserves, such as increasing legal immigration and closing a tax loophole for rich workers.

The reason for that nose dive is because, for the first time in more than 30 years, the Social Security system is running a deficit. That means that in 2017, the federal government cut more Social Security checks to retirees and disabled workers than it collected in payroll taxes from the current workforce. The federal government will have to start dipping into the $2.9 trillion trust fund to keep paying out benefits. This year, the government will probably have to take about $2 billion from the trust fund, according to the report.

Furthermore, Social Security now costs more than before because more Americans are retiring, and they are living longer. In 1960, about 5.1 workers supported each person receiving a retirement or disability check, and that ratio has been shrinking ever since. In 2013, there were 2.9 workers for every beneficiary. So the current level of payroll taxes is no longer enough to keep the program afloat.

But here’s how immigration could change that:

The number of immigrants in the US peaked in 2005, when the population had 2 million more immigrants than the previous year. That number reached a historic low in 2008 at the start of the Great Recession but has been ticking back up. In 2014, there were about 1 million more immigrants in the US than the previous year.

Even though the economy has improved as more immigrants join the US workforce, the Trump administration has insisted on restricting legal avenues for immigration. That will hurt Social Security, according to the SSA report.

If Trump allowed current immigration levels to stay the same (about 1.6 million more immigrants lived in the US in 2017 than the year before), then Social Security would have a better chance to stay solvent. The SSA’s estimates include authorized immigrants, unauthorized immigrants, and foreign workers on temporary visas.

As the chart shows, any growth in immigration lowers the Social Security deficit. The higher the growth, the lower the deficit.

According to the SSA, the reason is pretty simple. Immigrant workers tend to be younger, so they have a lot more years to work and pay taxes before they retire. But another reason that goes unmentioned in the report is that undocumented immigrants, ironically, provide an added boost to the system because they pay into the Social Security system, but they can’t receive benefits.

Undocumented immigrants pay billions of dollars in federal taxes each year. Payroll taxes for Medicare and Social Security are still withheld from their paychecks, even if they use a fake Social Security number on their W-2 form. The IRS estimates that unauthorized workers pay about $9 billion in payroll taxes annually.

A portion of the payroll tax withheld from undocumented immigrants — like all workers — goes into the Social Security Trust Fund (that savings account in the first chart). In 2013, the agency reviewed how much money undocumented workers contributed to the retirement trust fund. The number was even higher than average that year: $13 billion.

The chief actuary of the Social Security Administration, Stephen Goss, estimated that about 1.8 million immigrants were working with fake or stolen Social Security cards in 2010, and he expected that number to reach 3.4 million by 2040.

“We estimate that earnings by unauthorized immigrants result in a net positive effect on Social Security financial status generally,” Goss concluded in the 2013 review.

These numbers are a stark contrast to the often repeated rhetoric that undocumented immigrants are a drain on the US economy — rhetoric repeated by President Donald Trump. But working-class Americans, including many who voted for Trump, need immigrants to help pay for their retirement.

Congress needs to close the tax loophole

Boosting immigration alone isn’t enough to save the Social Security system. Immigration lowers the deficit, but it doesn’t eliminate it. One of the main problems is that low-wage and middle-class workers are paying a disproportionate share of their income into the Social Security system. More affluent workers don’t have to pay the 6.2 percent tax on any income they earn above $128,400, so a worker who earns $128,400 a year is paying the exact same amount in Social Security taxes as a billionaire. It’s basically a tax loophole for the wealthy.

In July 2017, a group of Congressional Democrats, led by Rep. Ted Deutch (FL) and Sen. Mazie Hirono (HI), introduced a bill to gradually phase out that cap. Under the bill, named the Protecting and Preserving Social Security Act, all wages would be subject to the 6.2 percent tax within seven years. It would also adjust the formula to calculate annual cost of living increases for retirees who get Social Security checks, so that the increase better reflects the spending habits of elderly Americans, who tend to spend more of their income on prescription drugs and energy bills.

The proposal would nearly close the deficit. An analysis by the Social Security Administration said it would keep enough money in the trust fund to pay retirees their full retirement benefits for an extra 25 years.

The bill was sent to three House committees. It’s been one year since then, and Republican leaders still haven’t put it up for a vote.