race condition fix