(Reuters) - CVS Health Corp CVS.N reported a bigger-than-expected quarterly profit as higher margins in its pharmacy business helped offset the loss of major contracts last year.

FILE PHOTO: People walk outside a CVS store in Pasadena, California, August 3, 2015. REUTERS/Mario Anzuoni/File Photo

Same-store prescription volumes fell 460 basis points in the first quarter due to the loss of contracts to fill prescriptions for Tricare, a U.S. Department of Defense health care program, and for customers of pharmacy benefits manager Prime Therapeutics, to rival Walgreens Boots Alliance Inc WBA.O.

However, higher generic drug dispensing rate and a cut back on promotions at the front-end of the store lifted gross margin in the pharmacy business by about 35 basis points to 29.4 percent.

Front-end same-store sales fell 4.9 percent in the first three months ended March 31. The company sells beauty products, snacks and over-the-counter drugs at the front-end of its nearly 9,700 stores.

Front-end same-store sales slipped for the fourth straight quarter and the company has been investing to turn around sales by improving the store layout and product assortment.

CVS reiterated its 2017 profit forecast and estimated second-quarter adjusted earnings largely below analysts’ average estimate of $1.33 per share.

The company’s shares were down 2 percent at $80.23 in morning trading on Tuesday. Through Monday’s close, they had gained 5.4 percent since Walgreens reported a surprise drop in sales last month.

Revenue in CVS’s bigger pharmacy services business rose 8.5 percent to $31.2 billion as claims increased across its network and on strong demand for its specialty pharmacy service.

The specialty pharmacy service provides expensive drugs to people with chronic conditions such as rheumatoid arthritis.

Net income attributable to CVS fell to $952 million, or 92 cents per share, in the first quarter, from $1.15 billion, or $1.04 per share, a year earlier.

Interest expenses declined 11 percent to $252 million, while the company also got $19 million in tax benefits from the adoption of new accounting guidance for share-based compensation.

Excluding items, the company earned $1.17 per share.

Revenue rose 3 percent to $44.51 billion.

Analysts on average had expected earnings of $1.10 per share on revenue of $44.20 billion, according to Thomson Reuters I/B/E/S.