Ruy Teixeira is the author of “The Optimistic Leftist: Why the 21st Century Will Be Better Than You Think.”

The Democrats had a very good midterm election in 2018. But 2020 is already looming, as is the biggest single contest of them all: defeating President Trump in the electoral college. The 2018 results — both the Democrats’ successes and their failures — illuminate how the Democrats might pull this off.

Think of it as a military campaign. From their coastal stronghold in the Northeast, the Democrats need to sweep into the Upper Midwest and down the Eastern Seaboard into New South states such as Georgia and Florida. And they also must push out from the Pacific coast and their emerging strength in the Southwest to threaten the other states such as Arizona and Texas that haven’t yet fallen to the Democrats. Each part of that campaign presents different challenges.

Start with the Upper Midwest. In the three states that are Exhibit A in how Trump won the 2016 election — Pennsylvania, Michigan and Wisconsin, all of which he carried by excruciatingly narrow margins — the Democrats came roaring back, winning Senate and gubernatorial races in all three. With the exception of Tony Evers’s victory over incumbent Republican Scott Walker in the Wisconsin governor’s race, which was quite narrow, all the other Democratic victories were comfortable. Democrats also easily won the governor’s race and two Senate elections in Minnesota, a state Trump made uncomfortably close in 2016.

The Democratic performance in Iowa and Ohio was more mixed. In Iowa, Democrats carried the House popular vote, flipped two House seats and now control three of Iowa’s four seats. Then again, Democrat Fred Hubbell lost his bid to unseat Republican Gov. Kim Reynolds by three percentage points. In Ohio, Democratic Sen. Sherrod Brown scored a solid reelection victory, but Democrat Richard Cordray came up short in his campaign for governor.

Where Democrats succeeded, how did they succeed? And where they failed, how did they fail? The formula for success in the Upper Midwest seems clear: Carry white college graduates, strongly mobilize nonwhite voters, particularly blacks, and hold deficits among white non-college-educated voters in the range of 10 to 15 points. Unlike Hillary Clinton in 2016 (she was obliterated among white non-college-educated voters in state after state), Democrats in Pennsylvania, Michigan, Wisconsin and Minnesota got all three parts of the formula right in the midterms.

Brown in Ohio got it right, too. According to exit polls, he carried white college graduates by five points and lost white non-college-educated voters by a mere 10 points. Cordray lost white non-college-educated voters by 22 points. In a state where white non-college-educated voters make up well more than half the electorate, that was enough to sink him.

Success against Trump in 2020 in the Upper Midwest will depend on repeating this formula. The necessity to keep down deficits among white non-college-educated voters, especially in rural and small-town areas, will be hard with Trump on the ballot. But the 2018 results show Democrats the way in the Upper Midwest.

In the Southwest, Democrats consolidated their hold over parts of the region in the midterms, with surprisingly easy victories in Nevada’s Senate and gubernatorial races (both Democratic flips), and winning governorships comfortably in New Mexico (a Democratic flip) and Colorado. In Arizona, Democratic Rep. Kyrsten Sinema won her Senate race against Rep. Martha McSally, another Democratic flip. And in deep-red Texas, Democrat Rep. Beto O’Rourke came amazingly close to unseating incumbent Republican Sen. Ted Cruz, losing by only 2.6 percentage points.

The Southwestern success formula: Carry or come close to carrying white college graduates; gain strong turnout and support from nonwhites, particularly Latinos; cap the deficits among white non-college-educated voters in the low 20s. Democrats can get away with higher deficits among white non-college-educated voters because the nonwhite share of voters in these states is much higher than in the Midwest.

In 2018, this formula worked in Nevada, Colorado, New Mexico and in the Arizona Senate race, with notably strong Latino support, but it failed in the Texas Senate race. Why?

O’Rourke also drew strong Latino support, and his performance among white college-educated voters was quite good for a Democrat in Texas. But his deficit among white non-college-educated voters was a disaster: O’Rourke lost these voters by 48 points, according to the exit polls. Democrats in 2020 will need to substantially reduce this deficit in Texas if they hope to compete there, while maintaining their relatively good 2018 performance among white non-college-educated voters in the rest of the Southwest, along with high levels of Latino mobilization.

In the South, though ballot-counting (if not recounting) continues, Democrats appear to have fallen just short in their bids for the governorships of Georgia and Florida, and in their effort to hold on to a Florida Senate seat. Both states have large nonwhite populations, though Florida’s is split more evenly between Hispanics and blacks, while Georgia’s is predominantly black. The trick for Democrats is carrying blacks overwhelmingly in both states, while solidly carrying Latinos in Florida (the state’s large, relatively conservative Cuban American population means Democrats can’t feasibly generate the 2-to-1 Latino advantage they typically enjoy elsewhere).

Democrats need to be competitive among white college-educated voters in Florida, while avoiding deficits among white non-college-educated voters that reach into the 30s. In Georgia, Democrats must keep their deficit among white college-educated voters under 20 points and stop their white non-college-educated deficit from ballooning out of control.

As the 2018 results show, Democrats in both states came very close to successfully implementing these formulas. The problem was that in Florida, the deficit among white non-college-educated voters was 30 points or a little higher and, in Georgia, the same deficit was a yawning 65 points. Whittle down those deficits, maintain nonwhite-voter mobilization and reasonable competitiveness among white college-educated voters, and Democrats have a path to victory in these key Southern states.

The Democrats’ marching orders for the 2020 campaign are clear, embedded in the midterm results. The challenge will be implementing them with President Trump on the ballot.

Read more: