A Court of Appeals ruling has upheld changes to Baltimore's pension plan that require first responders to serve an additional five years before being eligible for retirement benefits.

Maryland’s highest court acknowledged the difficulties for “employees who have devoted their careers to public service,” but said a city’s dire situation sometimes leaves leaders with little choice but to make hard financial decisions, the Baltimore Sun reports.

The lawsuit by Baltimore police and firefighters has been winding through the courts since a 2010 city council decision to change existing laws on when employees can retire and receive pension benefits. The justices agreed with lower court rulings that that the city had a right to change pension rules for those who had not yet qualified to retire, but couldn’t alter rules for those who had put in enough years to to be fully vested.

Additionally, the Court of Appeals ruling affirmed the lower court’s computation of $31 million in damages to retirees who had already earned their pensions.