Race condition fixed