race condition fixed