Big-box retailer Target said on Wednesday that losses caused by theft and organized retail crime, which had spiked in the first half of the year, are showing signs of stabilizing.

Target shares were up 3.5 percent at $129.40 in afternoon trading after the company’s second-quarter profit exceeded analysts’ expectations earlier on Wednesday.

In May, Target had warned that theft and organized retail crime was hurting profitability and could reduce it by more than $500 million, on top of the $650 million in losses it incurred in 2022.

Organized retail crime is defined as the phenomenon when gangs of thieves coordinate to steal millions of dollars of merchandise – often perfume, cosmetics, electronics or power drills – from retailers to then resell it on the black market. The reselling is generally at online auction sites and flea markets, and can even be done via third-party merchants on marketplaces like Amazon.com and Walmart.com.

While rising theft is impacting all retailers, including Walmart and Home Depot, Target has been the most vocal about the issue as it has struggled with excess inventories and disappointing margins. Its large concentration of stores in urban areas also makes it more vulnerable to higher levels of crime, analysts said.

Target said on Wednesday that losses stemming from theft dented margins by nearly 1 percentage point in the second quarter, a trend it expects to continue next quarter but ease as it enters the last two months of the year.

“So far, we’ve only seen indications that loss rates might soon be reaching a plateau, but have not yet seen evidence that loss rates will begin to come down,” Target CFO Michael Fiddelke told analysts on a conference call on Wednesday. He said the company would not be changing its $500 million inventory-loss forecast for the year.

The Minneapolis-based retailer has also had a spike in violent theft and confrontations between employees and customers at its stores. Threats and thefts involving violence at stores jumped 120 percent in the first five months of the year, Target CEO Brian Cornell said, calling it a trend that was “moving in the wrong direction.”

Some of the threats were related to the company’s LGBTQ Pride merchandise and were not all associated with theft, the company said. Target was embroiled in a controversy over its LGBTQ-themed merchandise in May that forced it to pull products from shelves after facing threatening behavior from shoppers.

Cornell on Wednesday said Target was working “tirelessly” with retail industry groups and communities to improve the safety of staff and customers.

Huntington Private Bank Senior Equity Analyst David Klink said it was encouraging to see Target increase its gross margins despite its struggles with retail theft. Target’s gross margin rate came in at 27 percent, or 5.5 percentage points higher than a year ago, and an improvement from the 26.3 percent in the prior quarter.

Klink, whose firm owns more than $10 million in Target shares, said he was disappointed earlier this year with the company’s first-quarter margin growth and the fact that it blamed the weakness on retail theft.

“If it’s weak (margins) and you claim it’s ‘organized crime,’ that raises eyebrows – the reverse not so much … So even holding the line on gross margins is a big positive for Target,” Klink said on Wednesday.