The basic principle of democracy, if nothing else, is that voters choose their own leaders. Once backed by the popular will, those leaders can then set policies and enact laws on the electorate’s behalf. Voters are fickle and their support can be fleeting, at least in theory, so the mandate to govern is periodically refreshed by regular elections.

That elementary idea is under siege today in the United States. Thanks to a surge in partisan gerrymandering over the past decade, American politicians increasingly choose their own voters, not the other way around. The result is ideologically entrenched legislatures that may no longer represent the will of the electorate as a whole, even though their members may accurately reflect their individual districts and constituencies.

Fortunately, the Supreme Court is weighing three cases on political gerrymandering this term that may provide a solution. On Wednesday, the justices will hear oral arguments in Benisek v. Lamone, where they’ll consider a First Amendment challenge to how Maryland Democrats redrew the state’s sixth congressional district in 2011. Slated for consideration next month is Abbott v. Perez, the latest chapter in a long-running battle between Texas Republicans and Hispanic voters over racial and partisan gerrymandering after the 2010 census. And at the center of the storm is Gill v. Whitford. The pending case centers on a map drawn by Wisconsin Republicans after they took control of the state legislature and governor’s mansion in the 2010 midterm elections. Using data from the 2010 census, GOP lawmakers used sophisticated computer programs to aggressively carve up the state’s legislative map into as many Republican-friendly districts as possible.

In some ways, Gill picks up right where the Supreme Court left off 14 years ago in Vieth v. Jubelirer. In that case, the justices weighed a challenge to Pennsylvania’s Republican-drawn congressional districts after the 2000 census. What resulted was a fractured decision that left no clear consensus on how to wrestle with partisan gerrymandering. Four conservative justices, led by Justice Antonin Scalia, concluded that the question was beyond the judiciary’s constitutional role and best left to the political branches. The court’s four liberal justices disagreed but failed to rally around a workable standard to determine which gerrymanders went too far and which ones did not.

As usual, Justice Anthony Kennedy sat at the center of it all. He sided with the conservatives on the immediate matter at hand and let the Pennsylvania map stand. But Kennedy also refused to foreclose judicial scrutiny of the issue altogether. “In my view, however, the arguments are not so compelling that they require us now to bar all future claims of injury from a partisan gerrymander,” he wrote. “That no such standard has emerged in this case should not be taken to prove that none will emerge in the future.”

The plaintiffs in Gill think they’ve found the solution to this long-running civic woe. A three-member panel of federal judges in Wisconsin struck down the state’s map in November 2016 using a tripartite test: To be found unconstitutional, a suspect map must be crafted with discriminatory intent, must have a discriminatory impact once implemented, and must have no other valid justifications for its arrangements. The panel’s majority concluded that Wisconsin’s post-2011 map met all three criteria.

To prove these criteria, the Wisconsin voters offered evidence of partisan asymmetry to the lower court by using a mathematical formula called the “efficiency gap.” Put simply, it’s an effort to find a quantitative measure of when redistricting goes too far in a political party’s favor. Gerrymandering can be achieved by concentrating a minority party’s votes into one district and/or scattering them across multiple districts. Under the efficiency gap, votes that don’t go to the winning candidate in those districts are considered to be “wasted votes,” which isn’t a value judgment.

“In an ideal world, both parties would waste the same number of votes, which would create an efficiency gap of zero,” Nicholas Stephanopoulos, a University of Chicago law professor who co-created the efficiency gap, explained recently. “When a district is gerrymandered by representatives of one party or the other, they try to maximize the number of wasted votes for their opponents and minimize the number of wasted votes for their own side.”

Ideally, a map would show a 0 percent partisan bias, but each state’s demographics rarely make this possible. “In the current [redistricting] cycle, [Wisconsin’s map] exhibited partisan biases of -12.6%, -11.6%, and -12.7%, respectively, in 2012, 2014, and 2016,” the voters told the justices. “In other words, had these elections been perfectly tied, Republicans would have won between 61.6% and 62.7% of the seats in the Assembly.”

This system isn’t without its skeptics. During oral arguments in October, Chief Justice John Roberts described the methodology as “sociological gobbledygook” that went beyond the court’s ambit. “Gerrymandering is distasteful,” Justice Samuel Alito conceded, “but if we are going to impose a standard on the courts, it has to be something that’s manageable, and it has to be something that’s sufficiently concrete” for the public to comprehend, he said.

Wednesday’s oral arguments in Benisek will approach the same subject from a different angle. While Gill focuses on Wisconsin’s legislative map as a whole, the Maryland case revolves around a single congressional district. A group of Republican voters are challenging the 2011 revisions of the sixth district’s boundaries, arguing that Democratic lawmakers shuffled around more than a half-million residents in western Maryland to weaken Republican voting power and throw another seat to Democrats in Congress.

“The practical consequences of this vote dilution were just as the mapdrawers intended,” the voters told the court in their brief. “Whereas Congressman Bartlett had consistently won reelection in the Sixth District by double-digit margins over the past two decades, Democrat John Delaney defeated Bartlett by a 20.9% margin in 2012.” Accordingly, they argued, the state trampled on the First Amendment’s ban on disfavored treatment against a group for its political views.

Maryland officials countered that the First Amendment doesn’t provide a workable test for courts to follow, as Kennedy demanded in Vieth. The voters urged the court to look to a district’s status quo ante when weighing partisan gerrymanders, but the state argued that such an arrangement would do more harm than good. “Using existing district configurations as the constitutional benchmark itself thus has an unintended partisan effect,” Maryland officials warned the court.

The stakes now could hardly be higher. Sam Wang and Brian Remlinger, who run the Princeton Gerrymandering Project, recently outlined three reasons why partisan gerrymandering is getting worse. First, growing partisan polarization over the last 20 years has made voter identities more predictable and therefore easier to manipulate. Second, the rise of computerized redistricting software allows for more precise and sophisticated map-drawing than before. Finally, one-party rule became an increasingly common occurrence in state legislatures and governors’ mansions, placing all the redistricting tools in a single set of hands.

States redraw their legislative maps every ten years to keep up with the decennial census. The most recent round of redistricting happened to coincide with the 2010 midterm elections, which saw massive Republican gains in state legislatures and in Congress. All in all, the surge placed 18 states under complete GOP control. “The net effect was one-party control over redistricting of 213 congressional seats and hundreds of legislative seats in large purple states such as Michigan, Ohio, Pennsylvania, North Carolina, and Virginia,” Wang and Remlinger noted.

Maps drawn under Republican control in those states had a profound impact on subsequent races. During the 2012 elections, the first held since redistricting, Wisconsin Republicans received 48 percent of the statewide vote but captured 60 of the 99 state assembly seats. According to WBUR, Democrats in Pennsylvania won 51 percent of the statewide vote that year but only captured 23 percent of the legislature’s seats. (The Pennsylvania Supreme Court struck down that map last month and drew a far more competitive one for use this November.)

The United States will hold two more nationwide elections—later this year and in 2020—before the next census forces another round of redistricting. Because of an election held eight years ago in 2010, Republicans in many states will enter the 2018 midterms with a sizable advantage. A Brennan Center for Justice report on extreme gerrymandering published last week estimated that Democrats would need to win the national vote by at least 11 percentage points this November to retake the House of Representatives.

“Neither Democrats nor Republicans have won by such an overwhelming margin in decades,” the report said. “Even a strong blue wave would crash against a wall of gerrymandered maps.”

The Roberts court doesn’t have a great track record when it comes to defending the integrity of American democracy, to say the least. The conservative majority’s 2010 ruling in Citizens United v. FEC ushered in an era of vast and largely unregulated spending on political campaigns; their 2013 decision in Shelby County v. Holder unforgivably gutted the Voting Rights Act’s protections. Reining in partisan gerrymandering wouldn’t undo the damage wrought by those two decisions. But it would be a much-needed step in the right direction for the republic.