Refactored for global and local deployments