fixed race condition
cleanup