What the hell is going on in West Virginia? On Monday, the House of Delegates impeached the entire state Supreme Court on charges focusing on the justices’ lavish spending on office refurbishments. Republicans, who led the drive to oust the whole bench, insisted the court was irredeemably corrupt. Many Democrats countered that GOP legislators were staging a coup to seize control of the judiciary. One justice, Robin Davis, resigned rather than allow herself to be removed, proclaiming that the impeachment push was a “disaster for the rule of law” and an attempt by the legislature “to dismantle a separate branch of government.”

While Davis isn’t wrong, the court isn’t wholly blameless either. Republicans are attempting to stack it—but the justices made that task easy by engaging in conduct ranging from questionable to certainly illegal. Republicans are citing the serious allegations against two justices to justify removing all four, and they have timed their attacks to ensure that Republican Gov. Jim Justice, rather than West Virginia voters, will be able to select their replacements, thereby dragging the court far to the right.

Start with the easy part. Menis Ketchum, a Democrat, repeatedly used a state-owned vehicle for personal use—including golf outings at a Virginia country club—and charged taxpayers for gas. Before he could be impeached, he abruptly resigned from the court in July and later pleaded guilty to one felony count of wire fraud for illegally using a state fuel card. Allen H. Loughry, a Republican, was indicted in June on 22 counts of fraud, false statements, and witness tampering. Federal prosecutors have accused Loughry of using state vehicles and credit cards for personal use. They also allege that he illegally moved a historic desk to his home and lied about it to federal investigators. He has been suspended without pay from the court but refuses to resign. Ironically, Loughry is the author of a book bemoaning corruption in West Virginia politics. He allegedly drove his state car to the Greenbrier resort in White Sulphur Springs five times for book signings despite a law limiting the car’s use to official business.

The allegations against the remaining justices are not so cut-and-dried. Chief Justice Margaret Workman, a Democrat, charged the court $111,035 for office renovations, including an $8,892 sofa. (Loughry outdid her with a $32,000 suede couch.) Justice Beth Walker, who ran as a nonpartisan candidate but is a Republican, got $130,655 in taxpayer money to upgrade her chambers. Justice Robin Davis, a Democrat, spent $500,278 to modernize her office. Big-ticket purchases included two floor rugs for $28,194 and an $8,098 office chair that, according to Davis, eased her spinal arthritis.

Whatever the merits of Republicans’ claims, it appears undeniable that they timed their blitz with the intent of shifting the court’s ideological balance.

Unseemly? Perhaps. Illegal? Probably not. Under an unusual law that the legislature may soon revise, the court has near-total control over its own budget. But West Virginia is currently facing a painful budget shortfall that led the state to slash pay for many public employees, including teachers. The justices’ decision to overhaul their workspaces in the midst of a statewide financial crisis is, at a minimum, unsavory. Similarly, Loughry, Davis, and Workman are accused of helping abet a scheme to overpay retired judges who filled in on circuit courts. This practice was not clearly unlawful, though it is difficult to defend in light of the state’s dire budget woes.

Can a justice’s distasteful but legal actions serve as grounds for impeachment? West Virginia law is ambiguous on this point. The state constitution allows the legislature to impeach and remove a judge “for maladministration, corruption, incompetency, gross immorality, neglect of duty, or any high crime or misdemeanor.” Ketchum, who has admitted to committing wire fraud, clearly falls into this category. Loughry, who’s accused of both flagrant misuse of taxpayer money and attempting to cover up that misuse, would also plainly fit the bill if those allegations are borne out. Workman, Walker, and Davis’ injudicious use of state funds, on the other hand, do not obviously qualify as impeachable offenses.

House Republicans have decided that the state constitution gives the legislature broad latitude to determine what qualifies as maladministration and corruption. Republicans impeached all four sitting justices, though Davis promptly retired to avoid removal. The articles of impeachment accuse the justices of fraud, ethical breaches, violation of their oaths, and “waste of state funds.” Loughry, Workman, and Walker will soon face trials on these charges in the state Senate. Republicans hold 22 seats in that chamber but need 23 votes to remove the justices from the court. It is unclear whether any Senate Democrats will join with Republicans to oust the rest of the court.

Although few Democrats expressed sympathy for the justices under fire, many accused their GOP colleagues of staging a power grab to subvert the separation of powers. They have a point.

West Virginia’s Supreme Court is elected, and before getting rocked by scandal, the current court leaned 3–2 toward Democrats. It was, by no means, a liberal court. But unlike, say, the Wisconsin Supreme Court, it has not aggressively bolstered the GOP’s agenda.

Now the governor and legislature appear eager to change that. The justices’ spending habits have been widely known since at least 2017, when a local news station published videos of the renovations along with their price tags. Republican legislators complained at the time but declined to take action on impeachment until this summer. Indeed, Democrats attempted to instigate the process much earlier, but Republicans dragged their feet until August.

The manner in which justices are replaced under West Virginia law makes this timing highly suspicious. If a justice leaves office at least 84 days before the next general election, voters will have the opportunity to replace her in that election. But if a justice leaves office less than 84 days before the next general election, the governor appoints a replacement who will serve for nearly two years—in this case, until May 2020—at which point the state would hold a special election.

Tuesday, Aug. 14 marked exactly 84 days before the November election. The House passed its articles of impeachment minutes before midnight on Monday, Aug. 13. Davis stepped down on Tuesday morning and made her retirement retroactive, effective Monday, so that voters will have the opportunity to replace her in the fall.

Loughry, Workman, and Walker have refused to follow suit. Instead, they have decided to defend themselves in the Senate. Of the three, Walker, an outspoken conservative with a devoted Twitter following, seems most likely to prevail. Republicans had initially spared Walker from impeachment for what looked like blatantly partisan reasons. But following Democratic complaints of hypocrisy, they charged her as well, both for excessive spending and for purportedly hiring outside help in drafting one judicial opinion. (Neither act is illegal.)

Whatever the merits of Republicans’ claims, it appears undeniable that they timed their blitz on the court with the intent of shifting its ideological balance without any check by voters. Gov. Justice, a close ally of Donald Trump, will appoint conservative Republicans to replace every justice the legislature removes. His appointees will serve until May 2020 before voters get the chance to replace them, surely enough time for the remade court to rubber-stamp Republican measures. Spending too much money on office furniture is a bad look for justices. Kicking out judges for partisan purposes is a bad omen for democracy.