Throughout the campaign, Donald Trump has issued dire warnings of foul play on Election Day. “I’m afraid the election’s going to be rigged,” he told supporters in Ohio. “I’m telling you, November 8, we’d better be careful,” he cautioned Fox News. “I hope the Republicans are watching closely, or it’s going to be taken away from us.” Trump’s remarks might seem like a cynical ploy to mobilize his base, or to set the stage for an aggrieved backlash should he lose to Hillary Clinton. In fact, however, the U.S. election system really is vulnerable—though not in the way Trump claims.

In July and August, Russian intelligence services hacked voter registration systems in Illinois and Arizona. But as menacing as foreign agents meddling with U.S. databases may seem, the biggest threat to the sanctity of the vote is the voting machines themselves. Like so much of America’s crumbling infrastructure, the systems we rely on to tabulate our votes fairly and accurately are in dire need of an overhaul. In thousands of precincts, the outcome of the election rides on equipment that’s outdated, prone to errors, and difficult or impossible to repair.

Ironically, what’s broken about America’s voting systems stems directly from the last major attempt to fix them. In 2000, the high-stakes recount in Florida threw an embarrassing spotlight on antiquated punch-card voting machines. To avoid more headlines about “hanging chads,” the federal government spent $3 billion to help states upgrade to high-tech, touch-screen machines. “People didn’t want that image of the guy with the magnifying glass and the chad,” says Pamela Smith, the president of Verified Voting, a nonprofit that monitors voting machines nationwide. “People were thinking: What’s the furthest thing away from a punch-card system?”

Almost from the start, however, the digital machines proved to be both vulnerable and unreliable. Many were built on 1990s-era software, making them easy targets for anyone who knew their way around computers. To demonstrate the potential for vote tampering, a group of computer scientists at Princeton hacked the machines in their lab, reprogramming one model to play Pac-Man. After voting machine manufacturers dismissed their findings, saying would-be hackers could never gain access to voting machines in the real world, one of the Princeton researchers took photographs of unguarded machines at local voting halls and posted them to his blog—a tradition he has maintained in every subsequent election. “When I go to vote, I realize that the people who most recently installed the software in that machine get to decide if it’s cheating or not,” says Andrew Appel, another of the Princeton researchers. “And the results may or may not have any relation to what the voters voted.”

Even worse, the new machines proved capable of screwing up elections all on their own, without any malicious tampering. In 2003, touch-screen machines in Virginia failed to record one vote out of every 100 for a school board candidate, reducing her overall tally by 2 percent in what proved to be a close race. The machines also crashed at a library polling place, a malfunction thought to have been caused by interference from a smartphone. Despite such obvious warning signs, the machines were eventually rolled out to jurisdictions across the state.