WARSAW, Poland (AP) — Poland’s parliament has passed a bill that will change how the country’s Supreme Court functions, a step critics see as an erosion of judicial independence under the populist Law and Justice party.

Lawmakers voted 239-171, with 24 abstentions, to pass the law on the Supreme Court, whose duties include confirming election results.

The lower house of parliament is set to vote later Friday on a separate bill that would change how judges are nominated.

The Venice Commission, a body of legal experts with Europe’s Council of Europe, a top human rights body, says the changes together constitute a “grave threat” to Poland’s judicial system.

The bills must also be approved by the Senate, where the ruling Law and Justice party has a comfortable majority, and then be signed by President Andrzej Duda. The president’s office has indicated he will enact them into law.