Refactoring deploy code