Refactor deployment functions