Rite-Aid (RAD 5.56%) has taken investors on quite a ride this year. Shares in the retail pharmacy chain have surged as the company has returned to profitability. But Rite-Aid's downbeat guidance is dinging investor euphoria. So with shares down big, here's what investors need to know about Rite-Aid's cautious outlook.

Challenging forecast

Rite-Aid remains the smaller sibling to giants CVS (CVS -0.62%) and Walgreens (WBA -0.06%). Those two companies combine to account for more than a third of all pharmacy scripts filled in the United States. But Rite Aid has been finding its footing in holding -- and in some cases building -- market share. A successful rewards program has buttressed front-end foot traffic. And expanding into additional vaccinations has attracted more customers.

Yet despite those positives, the company cut its full year sales forecast to between $25.3 billion to $25.42 billion and reduced its fiscal 2014 earnings per share guidance to $0.17 to $0.23 from $0.18 to $0.27.

That news sent shares down 10%, but before you get too excited, it helps to remember that short term news can sometimes give long term investors opportunities to buy companies on sale.

Returning to profitability

And that may be the case with Rite-Aid given net income in the third quarter climbed to $71.5 million from $61.9 million a year ago, representing the fifth consecutive quarter of profitability.

Supporting the bottom line growth was a 2.3% lift in same store sales, driven by a 3.5% jump in pharmacy sales. That trailed CVS Q3 same store growth of 3.6%, which was tied to a 5.8% same store lift in CVS's pharmacy sales. However, Rite-Aid's results were still solid, particularly given Rite-Aid's front end sales slid 0.2% while CVS's fell 1%.

Better pharmacy results came thanks to higher prices and more scripts filled, both important given they're being compared to last fall when results were buoyed by business won during Walgreens battle with Express Scripts last year.

It's not as bleak as some may think

Rite-Aid has been remodeling its best performing stores and these stores have been significantly outperforming other locations. Front end and pharmacy sales at stores with the new footprint were 3.2% and 1.4% better than at the un-renovated locations.

That suggests converting more stores to the new Wellness platform, and jettisoning more poor performing locations, could offer additional margin tailwinds.

And while brand drugs caught a bit of a breather this year in terms of patent expiration, generic competition is set to reaccelerate in 2014 and 2015. That suggests more margin-friendly new generics hitting stores shelves over the next two years.

It's not all roses and butterflies

Rite-Aid remains risky. It's made a big move this year and despite cutting its debt level, it remains highly leveraged with a debt to EBITDA ratio of 4.5 times. And while competitors CVS and Walgreens have diversified their business to include physician services and drug wholesale operations, Rite-Aid hasn't.

However, while leverage is high it is falling. And while profit may be slimmer next year than some may have thought, the company will remain profitable, generating an expected $250 million to $300 million in free cash next year.

That suggests investors who have missed out on Rite-Aid's recovery may want to take another look at the company, because its guidance appears to offer wiggle room for upside next year.

This Top Stock for 2014