fix a race condition.