In the past few years, many pundits have predicted the death of department stores. However, most department store chains posted better-than-expected results in Q2, sparking a relief rally for department store stocks.

On Thursday morning, the two top department store chains -- Macy's (NYSE:M) and Kohl's (NYSE:KSS) -- provided more good news for the sector. To be sure, department stores continue to suffer from weak customer traffic. But they are finding ways to get customers to spend more on each visit and making other improvements to their operational performance.

Kohl's recovery gains steam

Kohl's started off the day with a handy earnings beat. Adjusted earnings per share reached $0.80, up from $0.75 a year earlier. This was the second straight quarterly increase.

Earnings per share increased for a second straight quarter at Kohl's. Image source: The Motley Fool.

Comparable store sales did fall again, sinking 1.7% year over year. However, that was slightly better than the 1.8% decrease recorded in Q2 and significantly better than the first quarter's 3.9% decline.

Three months ago, Kohl's reported strong back-to-school sales near the end of Q2, and this trend continued into the beginning of Q3. September was weak, but sales trends accelerated again in October, with comp sales nearly flat during the month. This could be a good sign for the upcoming high-volume holiday shopping season.

Cost performance was equally strong. Kohl's reduced its selling, general, and administrative (SG&A) expenses by 1.7% in the quarter. Some of that improvement was due to the timing of various costs, but some of it reflects more efficient spending.

Finally, Kohl's cash flow was particularly impressive. The company is working hard to reduce its inventory without impacting sales. As a result, Kohl's has generated nearly $700 million of free cash flow year to date, compared to negative free cash flow in the first nine months of fiscal 2015. Investors applauded, sending the stock up as much as 15% on Thursday morning, to a new 52-week high.

KSS Chart

Kohl's stock performance. Data source: YCharts.

Macy's turnaround continues, but costs rise

Macy's also reported that sales trends are improving. For Q3, comparable store sales (including licensed departments) decreased 2.7% year over year. That was roughly in line with the Q2 decline of 2.6% and much better than Q1's 5.6% comp sales slump.

However, unlike Kohl's, costs increased significantly at Macy's in Q3. SG&A was up 5.2% year over year, driven by a combination of strategic investments to drive a return to sales growth, lower credit card income, and lower asset sale gains compared to Q3 2015.

As a result, Macy's adjusted EPS plunged to just $0.12 last quarter, down from $0.56 a year earlier, falling far short of analysts' estimates. Nevertheless, Macy's maintained its full-year guidance for adjusted EPS of $3.15-$3.40, due to its improving sales trends. The company expects comp sales to fall just 0.5%-2% in Q4.

Macy's made up for its mixed operating results by making a lot of progress on monetizing its real estate. During Q3, the company signed contracts to sell its men's store in San Francisco and its downtown store in Portland, Oregon, for combined proceeds of about $300 million. It also formed a strategic alliance with Brookfield Asset Management to explore development options for about 50 properties that Macy's owns.

Investors were pleased enough about the real estate progress and stabilizing sales trend to send Macy's stock up more than 8% on Thursday morning.

M Chart

Macy's stock performance. Data source: YCharts.

Comparisons get easier

Department stores will face very easy year-over-year comparisons for the next two quarters. Having two extra days between Thanksgiving and Christmas could also boost sales in Q4.

Both Kohl's and Macy's still trade at reasonable valuations -- as do most of their department store peers. If they can continue to execute on their efforts to reverse the recent declines in their earnings and cash flow, both stocks could rise even further in the next year or two.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.