Race condition fix