fixed race conditions