Among the more painful moments for Mark Zuckerberg in his second day of Capitol Hill grilling was the angry dressing-down he got from Rep. John Sarbanes. The Maryland Democrat zeroed in not on Facebook’s relationship with the data analytics firm Cambridge Analytica, but on the fact that Facebook (like Twitter and Google) had employees embedded with the Trump campaign to help craft its digital advertising strategy. For free.

That arrangement may have violated long-standing campaign finance rules that prohibit even in-kind donations from private companies to candidates. Perhaps more than any exchange Zuckerberg had with lawmakers, it is a clear reminder that everyone—including the big tech companies—would benefit from better, clearer rules.

Sarbanes’ questions were prompted by revelations in an October 2017 peer-reviewed study that documented the role employees from Facebook, Twitter, and Google played in “actively shaping campaign communications through their close collaboration with political staffers” on the Trump campaign. The companies have said they offered the same services to the Clinton campaign, which apparently declined the same level of help. That turned out to be a big mistake.

Both Trump and Clinton spent millions on Facebook ads, but the company’s own internal analysis concluded that Trump’s campaign, developed with the help of Facebook employees, was far more targeted and complex than Clinton’s, and “better leveraged Facebook’s ability to optimize for outcomes.” In the new world our campaigns have entered, in which behavioral algorithms can spin data collected by social media platforms on their billions of users into political gold, that gave the Trump campaign a critical advantage.

Companies like Facebook are not supposed to provide valuable services for free to presidential campaigns. Under federal law, if you provide goods or services to a campaign without charging fair market value, it’s classified as a contribution “in-kind.” Corporations have been prohibited from making such contributions since the days of Standard Oil. This is one area of campaign finance law that’s fairly rock-solid even in the post-Citizens United, dark money-fueled free-for-all that now characterizes US campaigns.

It probably doesn’t matter (at least for purposes of campaign finance law) that Facebook offered Clinton the same service. Campaign contribution rules do exempt certain benefits (like price discounts) offered to both political and nonpolitical customers as part of a company’s “ordinary course of business.” But it seems doubtful that the sort of tailored assistance Facebook provided to the Trump campaign would qualify.

Of course, Facebook didn’t necessarily want Trump to win. Despite the bromides about connecting the world, Facebook is in the business of selling ads, and it offered this service to help it do just that. The company’s obviously commercial motivations could create enough gray area to provide it with some cover (especially since tech companies reportedly helped the Obama and Romney campaigns in 2012 without being called out).

Even if Facebook broke the law, however, it’s far from clear the restrictions makes sense in this case. We arguably want companies like Facebook to work with campaigns and help them mobilize their supporters. That could, for example, result in more people turning out to vote and in more small-dollar donations to help counter the baleful influence of super PACs and shadowy dark-money groups that raise their millions from a handful of megadonors.

The bottom line is that Facebook’s business model is profoundly different from that of the print and broadcast media companies that used to dominate the political ad market. Left completely unregulated, that model poses significant risks to our political system. But existing rules, many of which are decades old, can often be a poor fit for technology that’s still, in the grand scheme of things, quite new.

It’s time to bring campaign spending and other laws governing Facebook’s conduct into the digital age. Zuckerberg made clear this week that he agrees—as he should, since whatever benefits Facebook gleaned from its relationships with the Trump campaign and Cambridge Analytica pale in comparison to the roiling PR disaster the company now faces.

Facebook and Twitter have both announced their support for the federal Honest Ads Act, a package of reforms that would bring more transparency to political ads on the Internet and help combat foreign meddling in our elections. As this week’s theatrics make clear, though, there is much more to do. It is in Facebook’s best interest, as much as anyone’s, to have clear rules of the road for everyone to follow. Hopefully the company and its Silicon Valley peers will take that lesson to heart.

Read more from Slate on Cambridge Analytica.