removing race condition