Reduced duplicate code in deployment.py