fixed race condition in undeploy