Philadelphia voters can rest assured Jim Kenney really was reelected mayor this month, according to a squad of data and voting experts from around the country who ran a rigorous statistical test of the results Thursday.

But while it’s no surprise that a Democrat won by 80 percentage points in an overwhelmingly Democratic city, it’s notable that the scientists were able to conduct such an audit in the first place. That’s because on Nov. 5, for the first time, Philadelphia used voting machines that leave a paper record of voters’ choices.

As Pennsylvania’s counties roll out similar new machines required to create paper trails in time for the 2020 presidential election, the reported electronic returns can now be checked for accuracy. That’s an important change in a state that Donald Trump carried in 2016 by slightly more than 44,000 votes, or less than 1%. Pennsylvania is expected to be critical again next year.

» READ MORE: Pennsylvania is critical in 2020. Here’s how Trump could win or lose it.

“We know we saw in 2016, everybody wondering, was this real, was this not real?" said Kathy Boockvar, secretary of the commonwealth, whose department oversees Pennsylvania elections. In 2020 and beyond, with what are known as risk-limiting audits, election officials will be able to confirm that the text of paper ballots lines up with what ballot-reading machines say.

“The stakes are high, people are very passionate, and we have the paper that will be able to show the actual evidence,” Boockvar said.

Officials hope the audits will make it harder for bad actors to tamper with the results. They also hope to increase public confidence in elections generally, following what U.S. intelligence agencies concluded was a systematic campaign by Russia to interfere in the 2016 election to boost Trump. (That campaign involved the dissemination of news and information Americans consumed, not the manipulation of actual votes or voting machines.)

Of the 60 ballots checked Thursday, 40 were cast for Kenney, 17 for Republican challenger Billy Ciancaglini, and two for write-in candidates. That authenticated what the machines had said, according to the algorithm behind the audit software.

The test was based on random sampling — the same method that allows pollsters to measure public sentiment without surveying every person. Sixty ballots was a large enough sample based on the reported margin in the race. A closer election would require sampling of more ballots.

In the all-electronic machines that most Pennsylvania voters had been using, votes are stored in digital memory. Any computer can be hacked.

“Literally a year ago, Philadelphia had no physical evidence of voter intent that voters even could have seen," said Mark Lindeman, who has coauthored several papers developing risk-limiting audits and works for Verified Voting, which participated in the audit. “It really was a black box system.”

The statistical audits do have limits in ensuring the security and integrity of elections. They can’t detect other ways of manipulating results, such as targeted voter suppression, or actual ballots disappearing or being replaced. The audit simply checks whether the text that is printed on ballots lines up with the reported results.

“Audits can read ballots,” Lindeman said, “but they can’t read minds.”

Despite their limitations, Bernhard and Lindeman said, Philadelphia’s new voting machines are a huge step forward from the old ones.

Philadelphia and Mercer County, in northwestern Pennsylvania, conducted the first audits this week. Boockvar said other counties are interested in the audits, and she expects to see them used in next year’s presidential election. She hopes to get state law changed to use the more rigorous audits. That would put Pennsylvania ahead of most states, which do not require risk-limiting audits.

“I’m really proud of Pennsylvania to be ahead of the pack on this,” she said.

Correction: A previous version of this story incorrectly identified one of the counties that conducted a post-election audit. It was Mercer County, Pa., not Mercer County, N.J.