fixed race condition possibility