avoid race condition.