Illinois may have the nation's most underfunded state pension system, but few jurisdictions are doing more to invite public-pension Armageddon than the city of Phoenix. The mess in Arizona's largest city highlights just how bad things can get when loopholes and bad policy all but eliminate the nexus between how much employees pay in and the pension benefits they end up receiving.

Arizona law prohibits public employees from using "unused sick leave, payment in lieu of vacation, payment for unused compensatory time or payment for any fringe benefit" to "spike" the final compensation on which their retirement benefits are calculated. But Phoenix police and fire contracts get around those prohibitions by allowing police officers and firefighters to receive extra monthly pay in lieu of accrued sick or vacation leave.

This column appears in our monthly Better, Faster, Cheaper email newsletter. Click to subscribe.

And as they say on those late-night television ads, "Wait, there's more!" Phoenix also allows bonuses, compensation for emergency shifts, and vehicle and cellphone allowances to be counted as salary for purposes of calculating pension benefits.

State legislators have done their part to contribute to this perfect storm of pension dysfunction. A Deferred Retirement Option Plan passed in 2001 allows police and firefighters to keep working for as long five years after they "retire." During that time, their pension benefit is deposited in a savings account. For years, the guaranteed annual interest was over 8 percent until the legislature cut it to 4.4 percent in 2011. (Anyone hired after January 1, 2012, is no longer eligible for the plan).

When those who retire under the deferred retirement option stop working, they receive accrued principal and interest in a lump-sum payment in addition to beginning to collect their regular pension benefits. So far, 10 public-safety retirees have collected lump sums greater than $700,000; each also receives an annual pension benefit of more than $114,000. Another 650 retired police and firefighters have collected lump sums of more than $250,000.

There is strong support for providing police officers and firefighters with more-generous retirement benefits than other retirees get due to the nature of their service. But at $59,341, the average annual Phoenix public-safety pension is more than twice the non-public-safety average for the city's retirees.

As you would imagine, all of this has taken its toll on the city budget. A decade ago, Phoenix budgeted $7.2 million for public-safety pensions; in 2013, the number is $109 million. Retirement costs are also one of the reasons why the police and fire departments have shrunk. In 2008, Phoenix had 3,375 police and 1,671 firefighters; by 2012, staffing had fallen to 3,021 and 1,578, respectively.

The latest twist came last week when the Goldwater Institute, a conservative public-policy think tank based in Phoenix, threatened to sue the city, claiming that allowing public-safety personnel to use fringe benefits to spike their pensions violates state law. It's no idle threat. A judgment declaring the practice illegal would unleash the ultimate political and fiscal nightmare by requiring the city to seek refunds from public-safety retirees, although the city might not have to recoup overpayments if it were to voluntarily change the policy.

The almost-infinite potential for gaming traditional public pensions highlights the need for a system that ties pension benefits to contributions. Defined-contribution and cash-balance plans are two ways to do that. Under defined-contribution, employers contribute a set amount toward employees' retirement. Cash-balance plans guarantee an annual interest rate on employee contributions and the employer's match.

Both could be tweaked to provide public-safety workers with enhanced pension benefits -- defined-contribution plans by hiking the employer match and cash-balance plans by guaranteeing the employees a higher annual interest rate. And it would be a lot more sustainable than continuing Phoenix's current practice of creating pension millionaires.