When YCharts recommended CVS Caremark (NYSE: CVS) a few months ago, investors were once again selling shares following a trouble-ridden earnings announcement. The company's Caremark division, a pharmacy benefits company that had pretty consistently disappointed everyone since its 2007 acquisition, reported only problematic progress from the final three months of fiscal 2010.

But what a difference a quarter can make. In a refreshing change, earnings released in early May showed performance at both CVS' retail stores and its Caremark business slightly beating forecasts. Buyers led the shares above the market for the first time all year.

Ychartsjune

The bigger share price gains may be yet to come. Investors learned late last week that Caremark won a $3 billion contract with Blue Cross Blue Shield Association to provide pharmacy benefits to federal employees. The deal was such a major coup that the loser of that contract, Medco Health Solutions (NYSE: MHS), initially lost about 9% of its value on the news.

CVS' recent share gains led YCharts Pro to change the shares' attractive rating from a few months ago to a neutral rating now. Based on the historic data YCharts tracks, the shares are only slightly undervalued today.

But the Blue Cross contract, which kicks in next year, points to more upside here than the company's past performance can indicate. With the strong fundamentals YCharts Pro cites, and the new sales the contract guarantees, today's share price still looks cheap. CVS is trading below the price earnings ratio of its main competitors in either the drug store or pharmacy benefits businesses.

Ychartsjune

The Blue Cross contract removes an element of uncertainty about CVS' business model, which should help focus investors on the shares again. Calls for CVS to dump Caremark had grown to an incessant chorus earlier this year from both investors, who hated the division's constant drag on profits, and competing pharmacy benefits companies, who claimed CVS could not fairly negotiate drug prices for insurers while selling pharmaceuticals directly to the public. Walgreens (NYSE: WAG), CVS's biggest competitor on the drug store side, sold its own pharmacy benefits company in March.

Now, CVS management says it has no intention of selling off Caremark. It promises the division will break its streak of earnings problems and show "healthy operating profit growth" in 2012.

That growth will complement the decent performance of CVS stores, which have been providing about two-thirds of the company's operating profits. Even with the drag from Caremark, the stores have pushed the company's revenues higher.

Ychartsjune

The company has several programs under way that should allow a healthy Caremark and CVS stores together to ramp up profits in ways that a company with only drug stores or only pharmacy benefits services could not. Overall CVS earnings are expected to grow more than 11.5% this year.

Meanwhile, CVS management is keenly aware of shareholder disappointment in recent years and has set aside about $30 billion over the next five years to make amends, some of which will go toward share buybacks. The company also promises a target dividend payout ratio of 25% to 30%. Even with a 43% dividend increase earlier this year, the company's payout is only at about 20%.

Ychartsjune

CVS still has to prove its ability to handle the Blue Cross contract in ways that will not permanently squeeze profit margins. But with management confidence about 2011 earnings, and a major customer in hand for the next several years, it's a lot easier to believe in the company CVS has promised to be for a long time now.

Ychartslogo

Dee Gill is an editor for the YCharts Pro Investor Service.

The Motley Fool owns shares of MedcoHealth Solutions. Motley Fool newsletter services have recommended buying shares of MedcoHealth Solutions. Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.