Prevent race condition attack