RALEIGH, N.C. (AP) — A federal judge ordered North Carolina on Wednesday to ensure that absentee ballots have a witness signature in a mixed ruling that allows voters to fix other minor problems without casting a new ballot from scratch.

Judge William Osteen issued an injunction requiring state officials to revise a directive issued Sept. 22 that let voters to fix a lack of a witness signature by returning an affidavit, but without starting a new ballot over and having it witnessed again. However, he said he would permit that kind of fix for small errors such as an incomplete witness address or a signature in the wrong place.

Osteen, who was presiding over three elections-related lawsuits, struck a middle ground between voting rights advocates concerned about restrictive absentee rules during the pandemic and Republican leaders who wanted more procedures returned to previous, stricter versions. He also declined to alter an extended deadline for county boards to accept absentee ballots after Election Day as long as they are postmarked by Nov. 3.

Osteen complained in his order Wednesday that the State Board of Elections’ late September rule update would have let someone cast a ballot without having a witness at all. He said that conflicts with a ruling he issued in August upholding the overall witness requirement in state law but requiring that voters be given due process to fix, or cure, minor ballot errors.

“This court upheld the witness requirement — to claim a cure which eliminates that witness requirement is ‘consistent with’ this court’s order is a gross mischaracterization,” he wrote.

Ballots with incomplete witness info and other errors have been in limbo since at least Oct. 3, with counties under instructions from the state board to take no further action on such problems pending court rulings. As of Wednesday, nearly 506,000 absentee ballots had been accepted, while another 13,000 have been set aside for a range of deficiencies.

It wasn’t immediately clear how many of them lacked a witness signature. Asked when the state board could issue new guidance to counties, spokesman Pat Gannon said attorneys were reviewing the judge’s order Wednesday night.

A lawyer for voting rights advocates who had filed one of the lawsuits said she was pleased with Osteen’s ruling.

“Today was a win for our clients and for all North Carolina voters who need to correct a problematic mail-in ballot,” said Allison Riggs, interim executive director of the Southern Coalition for Social Justice.

A higher court could still weigh in. The state elections board had already asked the 4th Circuit Court of Appeals to intervene at an earlier stage of the case. The Republican leader of the state Senate said he was willing to take the fight all the way to the U.S. Supreme Court.

Last week in court, Osteen expressed concerns that the updated procedure would essentially eliminate the witness requirement and could open the door to ballot fraud. He suggested that someone could skip having a witness entirely but then have their vote counted anyway by sending an affidavit to county officials.

State and national Republican leaders including President Donald Trump’s campaign argued in two federal lawsuits that the late September changes would usurp legislators’ power to set election rules that is enshrined in the U.S. Constitution. They also argued that the more lenient way of fixing witness problems would dilute the votes of those who followed the original, stricter instructions.

The Republican lawsuits had also sought to undo other rule changes, including one allowing county boards nine days — instead of three — to accept ballots that arrive after Election Day.

Osteen said that while he believed that change, in addition to the witness information procedure updated in late September, could result in unequal treatment of voters, he was limited by a legal principles that restrict how much courts can intervene to alter ballot rules close to an election.

North Carolina state Senate leader Phil Berger and House Speaker Tim Moore, who were fighting the state board’s rule changes in court, issued statements applauding Osteen’s ruling. Still, Berger said he believes that the judge could have gone further and said he wouldn’t rule out taking the case as far as the the U.S. Supreme Court.

“Judge Osteen concluded in no uncertain terms that the N.C. State Board of Elections violated the U.S. Constitution and North Carolina law by changing election laws after ballots had already been cast,” he said.