Barnes & Noble (BKS) revealed a surprise quarterly profit on Tuesday thanks to tumbling expenses, but the company’s sales fell more than feared.

Shares of the largest U.S. bookstore chain declined 4% in the wake of the mixed results.

Barnes & Noble said it earned $13.23 million, or 15 cents a share, last quarter, compared with a profit of $501,000, or a loss of 7 cents a share, a year earlier. Analysts had been calling for a loss of 3 cents a share.

Revenue fell 8% to $1.73 billion, trailing the Street’s view of $1.77 billion.

Gross margins expanded to 26.6% from 24.6% as selling and administrative expenses fell 7% to $386.27 million.

"During the second quarter, Barnes & Noble grew earnings through improved margins and reduced expenses, while also completing another successful College rush season," Barnes & Noble CEO Michael Huseby said in a statement.

Barnes & Noble reported a 7.5% decline in retail revenue to $921 million as same-store sales fell 4.9% and due to store closures. Barnes & Noble said college revenue dipped 4.6% to $738 million.

Nook sales tumbled 32.2% to $109 million amid continued competition from other tablets. Digital content sales dropped 21.2% to $57 million due to lower prices and unit sales. Device and accessories sales fell 41.3% to $51 million.

Looking ahead, Barnes & Noble reaffirmed its full-year guidance for same-store sales to decline in the high-single-digit percentage range.

Shares of New York-based Barnes & Noble lost 4.14% to $15.75 in premarket trading Tuesday morning. The company’s shares have underperformed the broader markets this year, rising just 9% compared with the S&P 500’s 26% rally.

Follow Matt Egan on Twitter @MattMEgan5