fixed the transaction race condition