A Texas man’s affair with a woman cost him nearly $9 million thanks to a little-known provision in North Carolina’s legal system.

Superior Court Judge Orlando Hudson ordered Texas marketing manager Francisco Huizar III to pay $8.8 million to North Carolina businessman Keith King on Thursday for having an affair with King’s wife. North Carolina is one of a handful of states that allows jilted spouses to sue affair partners, the Durham Herald-Sun reported.

King was able to sue Huizar for compensatory and punitive damages for civil charges including alienation of affection and criminal conversation.

King’s attorney Joanne Foil argued Huizar’s affair and alleged assault cost her client’s company, BMX Stunt Shows, money and an employee since King’s wife Danielle worked for the company.

King brought in text messages, hotel receipts, phone records, and Facebook posts to prove Huizar was the reason his relationship with Danielle went south, KABC reported.

Huizar’s attorney Cheri Patrick argued that King’s marriage had already been falling apart before Huizar first met Danielle at a BMX show in 2015, the Daily Mail reported.

Huizar said he plans to appeal the ruling because he only makes $84,000 a year as a marketing manager.

The Associated Press contributed to this report.