Announcing its second-quarter results on Tuesday night, Bed Bath & Beyond (NASDAQ:BBBY) met market expectations for earnings and beat expectations for comparable sales, setting the stock up for an after-hours surge. Bed Bath & Beyond, like many retailers, has suffered in 2014 as the promotional environment has cut into margins.

Earnings per share of $1.17 were at the bottom of analysts' forecasts, but the company's comparable store sales growth of 3.4% was above the expected 1% to 2% range. On the other hand, gross margin for the quarter was 38.5%, compared with 39.4% for the same period last year.

The first half still dogs Bed Bath & Beyond
Even with stronger than expected results overall, Bed Bath & Beyond continues to rest on its back foot. Last year, comparable sales for the first half were up 3.5%, while this year they're up just 2% over the same period. The fall in consumer interest helps explain Bed Bath & Beyond's 17% drop in share price over the past 12 months.

Like other retailers, this year's first quarter was one that investors and management are hoping to forget as soon as possible. A fall in transactions in the first period offset some strength in average tickets, as customers holed up and held on to their cash. This quarter wasn't enough to make up for the shortfalls of the first, although it did put Bed Bath & Beyond on a better trajectory going into the back half of the year.

Management looks for growth in the second half
On its conference call, Bed Bath & Beyond's management said that the decline in gross margin was due to a confluence of three factors. The first was an increase in coupon expenses resulting from higher redemption rates and more savings, on average. That's a reflection of Bed Bath & Beyond's long-time strategy of using coupons to get customers through the doors.

Second, the company was hit by a shift in its shipping expenses, as its online channel changed the threshold for free shipping.

Finally, there was some impact from an increase in markdowns and a shift in sales to lower-margin items.

Those are all going to help bring shoppers in, the company hopes, and help it finish out the year on a high note. Bed Bath & Beyond is looking for comparable sales to continue rising throughout the year, ending the full year with an annual increase of between 2.6% and 3.1%.

Looking forward
One of the most promising points about Bed Bath & Beyond's second quarter was its prudent use of cash. The company managed to increase its free cash flow from the same period last year, generating $398.4 million in 2014 versus $365.3 million last year.

The business also spent $1 billion on share repurchases, but it did so at a time when the company's shares were at a solid low point. That expense bought back 16.9 million shares, at approximately $59.17 per share. That's just 4% above the share's low point this year, and the stock traded above $67 overnight.

Overall, the outlook for Bed Bath & Beyond has definitely taken a turn for the good. While the company still has a way to go to be a roaring success, the second quarter was a step in the right direction. If the business continues to grow sales and use its cash wisely, this could be a very good year for Bed Bath & Beyond.

Andrew Marder has no position in any stocks mentioned. The Motley Fool recommends Bed Bath & Beyond. Try any of our Foolish newsletter services free for 30 days. We Fools don't 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.