Refactor deploy script