Refactor deploy controller