What could be more patriotic in our narcissistic social-media age than posting a picture of yourself on Facebook with your marked ballot for president? Show off your support for former Secretary of State Hillary Clinton, Donald Trump, Senator Bernie Sanders (D-Vt.) or former Florida Governor Jeb Bush. Last week, a federal court in New Hampshire struck down that state’s ban on ballot selfies as a violation of the First Amendment right of free-speech expression.

That might seem like a victory for the American Way. But the judge made a huge mistake because without the ballot-selfie ban, we could see the reemergence of the buying and selling of votes — and even potential coercion from employers, union bosses and others.

We haven’t had the secret ballot throughout American history. Indeed, before the rise of the “Australian ballot” printed by the government, political parties in some places printed their own ballots. Each party’s ballot would be a different color. There would even be parades to march people to the polls with their colored ballots. So it was very easy to see how people voted — and to reward or punish them if desired.

The secret ballot made vote buying and coercion that much more difficult. Sure, I can tell you I voted for the candidate you wanted me to — but how would you know if I were telling the truth? Indeed, turnout went down as each state adopted the secret ballot.

These days in the United States, vote buying is relatively rare. When it does happen, it usually requires the cooperation of someone in the polling place to verify how people voted or through an absentee-ballot scam. Consider this account from Judge Tom Glaze, author of Waiting for the Cemetery Vote, interviewing a political operative on how vote buying occurred in Kentucky into the 1970s:

Q: How do you make sure that that person votes your list? A: We’ve got a man on the inside. We have to have a judge inside. Of course, the judges are usually about the same ones, just like the same guys that handle the money [and] the same people sell-out year to year. The man inside will have different codes. One time it might be a grain of corn that he gives the man, and when he brings back this yellow grain of corn, for instance, we know the man voted right because our judge probably got to mark his ballot or he stood and looked over his shoulder. That way we sure didn’t want to spend money for a vote we didn’t get. Sometimes, if the other side gets wise to this and they go to giving out grains of corn, we will change and give out maybe a penny, a new penny, or just different codes that we used to know that the man voted right. Some cases, when you take them to the door, you walk close enough that you can see inside the polling place and see how they vote, to see if the judges are getting to mark their ballot or looking over their shoulder. Sometimes, the [election] judge will nod his head back at you that they voted right.

But it is not just the 1970s. We have prosecutions for vote buying every year, and many of them involve absentee ballots, where it is possible to see how someone voted and collect and mail their ballot.

In his 42-page opinion, Federal District Court Judge Paul Barbadoro offered an erudite and thoughtful discussion of the history of vote buying in the United States. You would think his analysis would have led him to uphold the ban. But it didn’t. Instead, his analysis fell apart in its legal reasoning.

The judge found correctly that New Hampshire’s law raised a First Amendment issue: It prevents someone from posting on Facebook a picture of herself doing something. Relying on the U.S. Supreme Court’s recent opinion in Reed v. Town of Gilbert, which subjected a town’s ban on certain road signs to strict scrutiny, Barbadoro held that New Hampshire’s law would also be subject to strict scrutiny. This means the state would have to show a “compelling interest” in its ballot-selfie ban and that the law was “narrowly tailored” to meet that interest.

Barbadoro ruled that preventing vote buying and coercion was a compelling interest in the abstract — but the state could not show that vote buying is a real problem now.

This analysis calls to mind Justice Ruth Bader Ginsburg’s dissent in the Supreme Court’s 2013 Shelby County v. Holder decision, in which she and Chief Justice John Roberts debated whether a part of the Voting Rights Act was still necessary to prevent racial discrimination in voting. Ginsburg said that getting rid of this part of the act while it appeared to be effective in stopping racial discrimination “is like throwing away your umbrella in a rainstorm because you are not getting wet.”

Similarly, the effectiveness of the selfie ban and the continued occasional prosecutions for vote buying, especially for absentee ballots, show that where there can be verification of how someone voted, this is a real — not theoretical — problem.

Barbadoro also said the law was not narrowly tailored, given that nothing would stop someone from posting on Facebook, or elsewhere, information about how he or she voted. What this analysis misses is that a picture of a valid voted ballot, unlike a simple expression of how someone voted, is unique in being able to prove how someone voted.

Indeed, it is hard to imagine a more narrowly tailored law to prevent vote buying. Tell the world you voted for Trump! Use skywriting. Scream it to the heavens. We just won’t give you the tools to sell your vote or get forced to vote one way or another.

The social-media age gives people plenty of tools for political self-expression. New Hampshire’s law is a modest way to make sure that this patriotic expression does not give anyone the tools to corrupt the voting process. Perhaps the judges of the 1st U.S. Circuit Court of Appeals or the U.S. Supreme Court will see the error of Barbadoro’s ways.