Fix undeploy function