NEW YORK (AP) — Target’s expanded online delivery options, new brands and updated stores helped drive shoppers to spend more during the critical holiday shopping season.

Target, which is trying to narrow the gap between itself and online leader Amazon, enjoyed a 31 percent spike in online sales. Comparable sales, which include sales at stores opened at least a year and online sales, rose 5.3 percent. It was the best performance since 2004 and surpassed the 5 percent growth that industry analysts had expected, according to a survey by FactSet.

Physical stores, which the company has dedicated billions of dollars to update and modernize, also realized gains. Target recorded a 4.5 percent increase in store traffic. The company says that it’s picking up market share across different areas, from fashion to toys.

“Our strategy is working,” Target’s CEO Brian Cornell told analysts at its annual meeting in New York Tuesday. But he cautioned, “We still have a lot to do…. This is no time to slow down.”

The company put out a better-than-expected forecast for the year, and shares rose more than 4 percent on Tuesday.

Target follows Walmart, Best Buy and several other chains in bucking some early gloomy U.S. government data reports on December sales, which cast a pall on the retail sector. Many retailers have been helped by a strong economy that brought higher wages and lower unemployment. But the financially healthy ones like Target have plowed money into sprucing up stores, and are expanding their online operations as they respond to shoppers’ shift to online shopping.

On Tuesday, Kohl’s also reported an increase in sales at stores opened at least a year for the holiday quarter and offered a rosy profit outlook. The company, which is on a mission to shrink its biggest department stores, said it will lease or sell the newly empty space at 10 locations to Planet Fitness.

Cornell says Target’s strong results aren’t just a reflection of the strong economy but also of its own reinvention efforts. He told investors that even if the economy slows down, its model can weather any environment.

Target announced in January that comparable holiday sales rose 5.7 percent in November and December from the same period last year. The Minneapolis company is among those that have expanded their toy aisles to capitalize on the demise of Toys R Us.

Target is spending more than $7 billion through 2020 to update its stores, open smaller stores in urban areas and expand its online operations. The company said it’s on its way to completing more than 1,000 store remodels by the end of 2020.It says it’s seeing an average 2 percent to 4 percent sales lift for every remodeled store.

The chain has overhauled its lineup of store brands and created new ones such as Pillowfort and Cat & Jack that have been popular with shoppers. This spring it will STOCK PHOTO launch three new exclusive brands in bras, underwear and sleepwear— Auden, Stars Above and Colsie — as it joins other retailers to take on Victoria’s Secret, which is floundering. Target also is teaming up with Vineyard Vines for a limited-edition collection that will hit stores and its website on May 18.

With increasing pressure from Amazon and shoppers’ demanding more convenience, Target has also expanded delivery services while capitalizing on the strength of its stores. To cut down on costs, stores have become shipping hubs, speeding up deliveries. Curbside pickup is now available at nearly 1,000 stores. It has rolled out sameday delivery service in more than 200 Target stores after acquiring delivery service Shipt for $500 million in December 2017.

As a result, three of four Target stores fulfill online orders now. Online sales reached $5.3 billion in Target’s latest fiscal year, accounting for 7.1 percent of total sales. That’s still a fraction of Amazon’s annual sales.

For the three months ended Feb. 2, Target reported $23 billion in revenue, beating the $22.92 billion forecast. It earned $799 million, or $1.52 per share. Its adjusted earnings were $1.53 per share, a penny better than Wall Street expected.

Target said it expects 2019 per-share earnings of $5.75 to $6.05. Even the low end of that range easily beats analyst projections of $5.61.

Target shares rose nearly 5 percent, or $3.34 per share, to close at $76.01, while Kohl’s shares rose more than 7 percent, or $4.87 to close at $71.34 on Tuesday.