With a number of races yet to be called, Democrats are on track to pick up as many as 37 House seats in this year's midterm elections. As many observers have pointed out, that total could have been higher had it not been for Republican gerrymandering in some states. A comparison of the 2018 House results in two states in particular — North Carolina and Pennsylvania — provides a vivid illustration of the power of gerrymandering to skew election results.

Gerrymandering happens when lawmakers draw legislative districts in a way that disadvantages their political opponents, either by packing them all up in a small number of districts to contain their influence or by splitting them across multiple districts to dilute their political clout. To see how it works in practice, look no further than North Carolina and Pennsylvania, where after the 2010 Census, Republicans drew maps to give themselves huge political advantages in U.S. House races.

Just how lopsided? In 2016, Democrats in North Carolina won 47 percent of the statewide popular House vote, but took home just 23 percent of the seats. Pennsylvania Democrats, meanwhile, won 48 percent of the statewide vote in contested House elections but only 27 percent of the seats. Big differences between popular votes and seat totals are one of the telltale signs of a heavily gerrymandered state.

But the two states' paths diverged after 2016. North Carolina held on to its gerrymandered districts for the 2018 election, just barely, despite multiple court rulings decreeing that the maps are unconstitutional. In Pennsylvania, on the other hand, the state Supreme Court redrew the maps earlier this year, in time for the election, creating a much more competitive electoral landscape.

The difference in the outcome at the ballot box is striking.

North Carolina, where the old maps were still in place, got an electoral result in 2018 that's virtually identical to 2016. Despite a Democratic wave in which more than half the state's voters opted for a Democratic House candidate, Democrats won just one-quarter of the contested seats.

In Pennsylvania, on the other hand, a 53 percent majority in the popular vote yielded just a hair under half of the contested seats — a big difference from 2016, when 48 percent of the vote gave Democrats just 27 percent of the seats.

The word "contested" is used deliberately here. In a small number of races in these states in these years, one of the major parties didn't field a candidate. Those races have been excluded from this analysis, since they result in ballots cast for only one political party.

North Carolina and Pennsylvania were analyzed because they were frequently rated as the most gerrymandered states in the nation on a number of different measures, and because they saw intense litigation and public debate over gerrymandering this year. They both happen to be GOP gerrymanders, although Democrats have a record of doing this too — Maryland being the most noteworthy example.

Considering all seats in these two states, contested and otherwise, Pennsylvania's House delegation moved from 11 Republicans and seven Democrats before the election to a 9-9 split after, a result that's much more in line with the statewide popular vote than in previous years.

In North Carolina, however, the results are unchanged: Democrats held three seats before the midterms, and they'll hold three seats afterward, despite increasing their state popular vote share in contested elections by 5 percentage points.

In these abstract discussions of seats and vote tallies it's easy to lose track of what this actually means from a governance perspective. Judge James A. Wynn Jr. of the U.S. Court of Appeals for the Fourth Circuit offered some big-picture perspective in a ruling against the constitutionality of North Carolina's gerrymandered map earlier this year. He lamented that voters in the state "have been deprived of a constitutional congressional districting plan — and, therefore, constitutional representation in Congress."

Proper representation in Congress is one of the cornerstones of U.S. democracy — the whole system is built upon it. Gerrymandering gnaws away at that representation, making it difficult for voters to elect a government that represents their will.

One underappreciated aspect of Tuesday's elections is a shift in the balance of redistricting power, from Republicans toward Democrats and independent commissions. If Democrats continue to build on those gains in 2020, it'll be a chance to see whether they're truly interested in drawing fairer maps or whether they just want to tip the scales in their favor.