Twitter Inc. (TWTR.N) reported sales that beat Wall Street expectations as the social media company attracted millions of new users with better ways of sorting users’ feeds and more relevant notifications. The shares rose about four per cent in early trading in New York.

Second-quarter revenue came in at US$841 million, up 18 per cent from the same quarter last year and higher than the US$829 million analysts estimated. The company added 5 million daily users in the period, bringing the total to 139 million. That was the biggest year-over-year increase since the summer of 2017.

Net income, excluding certain items, was US$37 million, or 5 cents a share. That compares with US$58 million, or 8 cents a share, a year earlier, Twitter said.

The most notable blip in the report was guidance: The company expects third-quarter revenue to be between US$815 million and $875 million. On average, analysts were looking for sales of US$872 million. One reason for the softer forecast: Twitter plans to retire some ad formats in coming quarters.

“We’ve made the decision to shut down some revenue products that were big enough that they might impact near-term revenue, but small enough that they weren’t long-term priorities,” Chief Financial Officer Ned Segal said. “Instead, we are focused on our most important products, delivering higher performing, better formats for our customers.”

Twitter has turned a profit in seven straight quarters and user numbers have steadily risen in the past two years. That follows a decade of losses, executive reshuffles, layoffs and declining usage.

A more persistent problem is the behavior of spammers and trolls on Twitter’s service. The company said on Friday that it continues to battle these bad actors.

“Health is our top priority,” the company wrote in its earnings release, saying efforts to spot and address malicious activity resulted in an 18 per cent decline in reports of spammy or suspicious behavior.

Future sales growth may come from expanding advertising overseas. Just 21 per cent of Twitter’s daily users are based in the U.S., yet 52 per cent of its revenue comes from the country. That means the company can either show more ads to international users, or try to raise ad prices in other countries.

A second opportunity is the 2020 U.S. election. President Donald Trump is Twitter’s most famous user, and the social media service has already hosted numerous spats between candidates. That keeps people logged on to Twitter, but also raises free speech questions.

Trump was found to be violating the first amendment for blocking critics on the network, and he has slammed political opponents from his Twitter account. He’s also accused Twitter of bias and making it harder for users to follow his account. Trump has more than 62 million followers.

Still, Twitter didn’t see significant revenue growth from political ads during the 2016 Presidential election or 2018 U.S. midterms. So the 2020 election may simply provide Twitter with more of the social influence it already has.

Bloomberg LP, the parent company of Bloomberg News, produces TicToc, a global breaking news service for Twitter.