(Reuters) - A new Kentucky law aimed at addressing the state’s unfunded pension liability is unconstitutional and should be voided, according to a lawsuit filed on Wednesday by the state’s attorney general and groups representing teachers and police officers.

Democratic Attorney General Andy Beshear said a temporary restraining order was also being sought in Franklin Circuit Court to prevent the law from taking effect.

“This bill is bad, it’s dangerous and it won’t work,” he told reporters, adding that the bill’s March 29 passage resulted from a “backroom deal” by Republicans, who control the legislature.

The lawsuit claims the bill, which was signed into law by Republican Governor Matt Bevin on Tuesday, violates state statutes and constitutional provisions related to public employee contracts and legislative procedures.

Elizabeth Kuhn, Bevin’s spokeswoman, called the lawsuit a politically motivated move by the son of Kentucky’s former governor.

“Over eight years, former Governor Steve Beshear underfunded the pension system by billions, recklessly diverting much-needed funds to other causes and allowing the system to become the worst-funded in the country,” Kuhn said in a statement. “Now, the attorney general is carrying on the Beshear family legacy by trying to block a law that will strengthen our pension system.”

The legislation, which puts future teachers into a less-generous retirement plan and restricts the use by all workers of accrued sick days toward retirement eligibility, sparked protests by teachers at the state capitol in Frankfort.

According to the lawsuit, pension language was inserted at the last minute in a bill originally dealing with local sewers, public access to legislative meetings on the bill was restricted and no actuarial analysis on the bill was prepared.

Kentucky ranks near the bottom among the 50 states in terms of the financial health of its retirement system. Based on 2016 actuarial assumptions, Kentucky’s pensions were 52.7 percent funded with an unfunded liability of nearly $33 billion, according to a state website that said more conservative assumptions would increase the liability to at least $64 billion.