fixed race conditions'