Thanks to a one-time bonus added to their final paychecks, cops in one Illinois town were boosting their annual pension payouts by more than $20,000 annually—until a court slammed the loophole shut this week.

The magic trick worked like this: For years, the Chicago Tribune reports, police officers in Countryside, Illinois, had a tradition of giving retiring officers an $850 bonus in their final checks. It was more than just a nice going-away present. Because pensions in Illinois are calculated based on a retired public employee's "final rate of pay," the pension board for the police department would report retired officers' final paychecks as if they were a normal, bi-weekly paycheck. In other words, that $850 one-time bonus would be made to look like it was part of the cop's normal pay, duplicated across 24 pay periods per year.

Do the math: $850 times 24 equals $20,400. Thus, in the eyes of the pension system, each officer was due a pension based on a final salary more than $20,000 in excess of the pension actually earned.

Why did the pension board go along with the scam? Probably because its members are current officers and retirees.

The Illinois Supreme Court issued an order Wednesday making the scheme illegal, but it said retirees who have gamed the system do not have to give back their excess pension payments. According to the Tribune, a handful of former officers have used the gimmick to collect more than $100,000 each in extra pension pay over the course of several years.

As pension gimmicks go, that's a pretty creative one. Like all similar pension schemes, it reveals one of the major flaws with the so-called "defined benefit" pension plans that are most common in the public sector.

In a defined benefit system, a worker's pension is based on a formula that takes into account the worker's final salary (sometimes an average of his or her salary over the last five years or so) and the amount of time they spent working in the public sector. Play around with either of those two numbers, and an employee can end up with a much larger pension than the rules suggest he or she should. In pension parlance, this is known as "spiking."

There are many ways to do spike a pension. A cop in New Jersey spent nine years on paid leave but continued to accumulate seniority to boost his final pension amount. For more than a decade, the New York Police Department ran an elaborate scheme that allowed dozens of cops to qualify for boosted pensions by claiming to be disabled when they really weren't. Until recently, California allowed public employees to literally purchase up to five additional "years" of service when they retired—effectively allowing someone to retire at 60 but with a pension that assumed he or she had worked until 65.

One of the major benefits of switching to a so-called "defined contribution" retirement system, like the 401(k) plans common in the private sector, is that those sorts of games and gimmicks no longer work. Your retirement benefits are the result of your own investments, not a guaranteed payout backstopped by taxpayers, based on a formula that can easily be abused without proper oversight.

The Illinois Supreme Court did the right thing by cutting off the ridiculous loophole in Countryside.