This year, judges in California and Michigan approved the exit plans of two of the largest municipal bankruptcy filings in the country’s history. In California, Stockton upheld its obligations to the state’s pension system behemoth, Calpers, while paying its other creditors as little as pennies on the dollar. Detroit, meanwhile, was able to restructure its obligations to all of its creditors, including city pensioners. While the exit plans differed, both judges ruled similarly: public pension obligations could be shortchanged like any other debt.

Stockton and Detroit aren't alone. Cities and states across America are facing catastrophic budget shortfalls. After decades of promising municipal employees pensions and healthcare benefits, municipalities do not have the savings to pay them out. According to a Pew report released last year, some cities had only 50 percent of the funds needed to cover pension promises, and Charleston, West Virgina, had only 24 percent funding. Now, paying off these shortfalls—and serving the debts incurred—is taking up a growing portion of municipal budgets, at the expense of essential public services.

Kim Rueben, a senior fellow at the Urban Institute, calls Illinois “the basket case of all of these pension cases.” For decades, Illinois and most states have hired public employees and promised them generous pensions upon retirement. But as an analysis by the Center for Tax and Budget Accountability for the Illinois 2014 budget reported, Illinois got into trouble “by diverting what it owed to fund benefits to instead subsidize the cost of providing public services. Through this process, the state effectively borrowed billions of dollars from the pension systems, using them like a credit card.” Now, the state faces a pension deficit of $111 billion. This year, Illinois’ budget dedicated almost one in every five dollars to funding pension obligations—and 80 percent of that amount was spent servicing the debt itself instead of lining retirees’ pockets.

It’s not just Illinois that screwed up. In September, a Moody’s Investors Service report found that the 25 largest public pension services in the country, like the California Public Employees’ Retirement System (Calpers) and the New York State and Local Employee Retirement System, face around $2 trillion in unfunded liabilities. The Chicago Sun-Times reports that the city’s pension liability amounts to almost $20,000 per Windy City resident, and as Frank Shafroth, director for the Center of State and Local Leadership at George Mason University put it, “Atlantic City is in really deep doodoo.” Towns you’ve never heard of all over the Midwest are struggling as their populations shrink and age, leaving fewer people to pay for the growing pension demands of their public servants. “It's like half the kids got off the teeter-totter, and the other half stayed on it and they’re staying on it for longer,” Shafroth says of the demographic shift. “It’s unbalanced.”

A municipal bankruptcy is certainly not an ideal way to balance those obligations. It’s woefully expensive—Detroit’s fees are not yet finalized but hover around $150 million—and doesn’t instill confidence in potential creditors. Previously, the conventional wisdom was that cities didn’t file for bankruptcy, especially since most state constitutions seemed to protect pension obligations, even in bankruptcy. But the decisions in Stockton and Detroit found that federal law, which says that the measly spoils of bankruptcy must be doled out fairly to creditors, trumps the state law protecting the promises to pensioners. Pensions for public employees are just another contract, not a sacred covenant, and that means a city can cut its most crippling obligation.