BlackBerry Ltd (NASDAQ:BBRY) released its latest earnings report before opening bell this morning, posting adjusted earnings of 4 cents per share on $286 million in GAAP revenue and $297 million in non-GAAP revenue. Analysts had been expecting the company to break even on $288 million in revenue. In the year-ago quarter, BlackBerry reported $464 million in sales.

BlackBerry BBRY earnings

BlackBerry’s losses narrow

The company posted a GAAP loss of 10 cents per share, a vast improvement from the 45 cents per share in lost in the same quarter a year ago. BlackBerry’s software and services revenue amounted to $166 million, while mobility revenue was $82 million. The company’s non-GAAP gross margin was 65%, while its GAAP gross margin was 60%. Adjusted EBITDA was $42 million, marking the 13th quarter in a row in which it was positive.

Cash flow from operations was $19 million, while free cash flow was $16 million. The company added $89 million to its total cash balance, bringing it to $1.7 billion at the end of the fourth fiscal quarter. Management said their fourth quarter results were “at or above” their expectations in all “major metrics. They kept growing their mix of software and services revenue, expanding the operating margin so that the company could post positive free cash flow.

“In our areas of strategic focus, we are executing well and gaining traction,” Chief Executive John Chen said in a statement. “In our enterprise business, we had one of our best-ever software billings quarters, driven by strength across regulated and non-regulated industries.”

He also noted that they secured six new customer trials for their Radar technology and demonstrated their autonomous driving technology at the Consumer Electronics Show earlier this year. BlackBerry also signed its third major agreement for mobile software licensing, securing global coverage with that deal.

BlackBerry’s results improving

BlackBerry said it expects to generate positive free cash flow and be profitable on an adjusted basis in fiscal 2018. The company expects its software business to grow “at or above the overall market.”

Shares of BlackBerry surged by as much as 4.32% to $6.95 in premarket trading on the NASDAQ after this morning’s earnings release.