Fundamentally, there's a lot to love about Costco (NASDAQ:COST). The company takes a long-term view of its business, management has its head in the right place, and customers absolutely love the place. In fact, there are few downsides to the business. That's why Costco has been a Motley Fool favorite since the beginning and why you won't find much bashing of the company, even in this article telling you not to buy it.

If there's a problem with Costco -- and that's not to say there is -- it's that everyone knows how good it is. If we want to be greedy when others are fearful, we're going to have to step away from Costco's solid earnings and strong customer base. If we want to face down fear and be greedy, we need to go to J.C. Penney (NYSE:JCP).

Looking beyond failure to find success
You still here? Great. Let's take the first big step toward accepting J.C. Penney as a real investment target and look at the company's earnings statement. In the last quarter, our hero raked in the cash, losing $0.56 per share. That's not going to get anybody excited about the company, so let's look a little deeper.

First of all, that $0.56 per share loss was a step in the right direction from the previous year's second quarter, when the company lost $2.66 per share. This year's first half is on the right track, having lost only $1.72 per share compared to last year's $4.24 per share loss over the same period.

Not only are we on the right track, we're also making a lot of headway. Comparable sales for the quarter were up 6%, compared to last year, meaning each store is doing more. Comparable store sales for the half are now up 6.6%, which is a world away from the first half of 2013, when comparable sales were down 14.3%.

Now, I know -- the rise this year is from a low base and it's still not enough to make any money. Take a peek at one last point in J.C. Penney's filing: cash flow. Last quarter, J.C. Penney generated positive free cash flow for the first time since 2011. The sweet smell of $76 million in cash is quite refreshing for a company that's been burning through its savings.

Turning the seed in a tree
J.C. Penney still has a long way to go if it wants to turn that free cash into real earnings. The retailer still has over $5 billion in long term debt and only $1 billion in cash. To that end, though, gross margin and operating margin are creeping up. Those increases have come on the back of a return to the customer base that fled the brand when Ron Johnson took the helm back in 2011.

Now that the customers are coming back, J.C. Penney's management is focusing on getting them in more often and making them more likely to open up their checkbooks. That's going to involve an increase in product sales in the store's core competencies, which, management thinks could lead to an additional $1 billion in sales over the next three years.

J.C. Penney is also going to be investing in its omni-channel offering, allowing customers to make purchases more easily. It's renovating locations and shifting store layouts to make shopping more appealing, and it's doing all this with an eye to keeping its free cash flow positive.

The upside for J.C. Penney investors
Let's look back at the premise: J.C. Penney is undervalued and Costco's value is known. Compare the two on a cost per sales basis, since J.C. Penney isn't earning income: Costco is trading at 0.51 times its sales, while J.C. Penney is at a lowly 0.19.

Admittedly, not a lot of analysts love J.C. Penney, but of those that do, Citigroup has rated it a buy with a price target of $11 -- a 44% increase from today's price. Costco, on the other hand, is rated a buy with a $150 price target, a mere 13% increase above today's price.

I went a long time being skeptical about J.C. Penney's future, but after visiting a few in my area, seeing the work that the company has done in the stores, and being impressed by management's cash management, I've become a believer. I still love Costco -- and every investor needs to make their own risk rewards calculation -- but I'm looking for upside in a tight market, and J.C. Penney looks like an unsung hero to me.