fixing a race condition.