A West Virginia man was lucky after a bad beat in poker on Thursday.

KDKA reports that Benjamin Flanagan, of West Virginia, played poker at Rivers Casino when a royal flush beat his four aces during no-limit Texas hold’em. 

Raymond Broderson, of Wexford PA won over $368,000 with his royal flush.

Flanagan’s beat turned into his gain because the loss triggered the ‘bad beat jackpot’

The news outlet reports that the bad beat jackpot was over $1.22 million and it was split between the six remaining players at the table.

The 1.22 million bad beat jackpot was the biggest jackpot prize at Rivers Casino. The previous record was $480,000 set in 2017.