Fix potential race condition in the deployment