avoid race condition