(Reuters) – BlackBerry reported a smaller-than-expected fiscal third-quarter loss on Friday and its first quarter-to-quarter revenue gain in over two years, indicating turnaround efforts may be gaining traction.

The better-than-expected results, driven by higher hardware and software revenues, sent BlackBerry shares up 5 percent in early trading in New York and Toronto.

“I’m pleased with our progress and the growth in Q3,” said Chief Executive Officer John Chen, on a conference call. “Our results demonstrate that we’re executing on the turnaround.”

In the quarter ended Nov. 28, the Waterloo, Ontario-based company reported a loss of $89 million, or 17 cents a share. That compared with a year ago loss of $148 million, or 28 cents a share.

Excluding a noncash credit tied to a change in the value of debentures, restructuring charges and other one-time items, the company posted a loss of $15 million, or 3 cents a share.

Quarterly revenue fell 31 percent to $548 million from a year earlier, but rose 12 percent from the prior quarter, after nine consecutive quarters of declines.

Analysts, on average, expected BlackBerry to post a loss of 14 cents a share on revenue of $489 million.

Software revenue, a metric being closely watched by analysts as BlackBerry pivots to focus on that segment, more than doubled to $162 million from a year earlier.

“BlackBerry hit a software number that investors have been looking for them to hit for quite some time,” said Morningstar analyst Brian Colello.

Year-to-date software revenue is about $362 million, within striking range of the company’s forecast target of $500 million for the current fiscal year ending Feb. 29, 2016.

Revenue from smartphone sales also rose for the first time in four quarters to $214 million from $201 million in the second quarter.

It sold 700,000 devices in the latest quarter down from about 800,000 in the prior period, but average selling prices (ASPs) on devices jumped to $315 from $240.

The ASP increase came after BlackBerry recently rolled out the Priv, its first device powered by Alphabet Inc’s Google Android operating system. BlackBerry said it sees its hardware arm possibly returning to breakeven operating profit in the current quarter.

Significantly, gains in software revenue more than offset a decline in BlackBerry’s legacy system access fees this quarter. BlackBerry said it expects the trend to continue, helping it beat both top-line and bottom-line Wall Street expectations in the ongoing quarter.

BlackBerry stock was up 63 cents to $8.43 in New York and 96 Canadian cents to C$11.85 in Toronto.

(Editing by Jeffrey Benkoe)

Get more stories like this on TwitterFacebook