Rite Aid (NYSE:RAD) is under-loved.

There is a stigma about this pharmacy business, which is still recovering from its aggressive acquisitions in the late 1990s. However, it's evident that the company has finally positioned its core pharmacy business in the right direction.

And while sales continue to inch higher, more importantly, store productivity continues to improve. Same-store sales for the four weeks of December were up 2.6% from last year, helped by a pharmacy same-store sales increase of 4.1% and a front-end same-store sales increase of 0.6%. Sales for December were down based on one fewer week (literally seven fewer days), but on my calculations, the average daily sales count was up from $51.5 million to $53 million.

I was amazed that for all of the turmoil Rite Aid has endured over the past eight years, it has had at least 115 straight months of improving same-store sales. It's evidence of the underlying strength of the pharmacy business. To be fair, that statistic hides the glaring fact that over the same period, Rite Aid has managed to reduce its store count from 4,010 stores to 3,321 stores (as of yesterday's sales report).

Regardless, the statement of cash flow shows that over the past seven years, capital expenditures have been less than depreciation. This tells me that the productivity gains are coming without a massive overhaul of the existing store base. Rather, most of the pain is on the income statement, where Rite Aid continues to have a line item for store closures.

Unfortunately, comparable same-store sales are slowing, and it seems that Rite Aid has reached a point where it has weeded out most of the underperforming stores. So while I would prefer that management continue to pay down its debt, which has already been reduced by $3.5 billion over the past six years, it does need to take the next step forward.

To gain additional operating leverage, Rite Aid is leveraging itself again in a deal with Jean Coutu to create an expanded store base of 5,000 stores. To manage sustainable profits in this competitive environment, which includes lower margins on Medicare Part D benefit plans and Wal-Mart's (NYSE:WMT) $4 generic-drug plan, Rite Aid must gain scale. With this move, it will still rank third behind Walgreen (NYSE:WAG) and CVS (NYSE:CVS). However, Rite Aid will stand a better chance of regaining profitable operating margins.

I believe the market is betting Rite Aid won't pull it off. However, if Rite Aid does manage 5% operating margins, this pharmacy chain's shares will get the love I think they deserve.

For related Foolishness:

Foolanthropy is celebrating its 10th year -- and there are only three days left! To learn more about our five Foolish charities or to make a donation, visit www.foolanthropy.com.

Wal-Mart is an Inside Value recommendation. Philip Durell is the consummate bargain hunter, whether he's digging up a great business at a good price or unearthing a turnaround situation. To see how he's beating the market, click here for a free trial.

Fool contributor Matthew Crews welcomes your feedback -- really! He has a financial position in CVS, but in none of the other companies mentioned. The Motley Fool has a disclosure policy.