Fix to race condition