The suggestion of @marsW is a good one to prevent your script to send multiple failing transactions.
However, it’s currently a matter who is sending their tx in the first block that is timestamped 1800 seconds after the last successful work, with the highest gas.
I have just described the situation in another topic: Bot war: Failing txs