cli refactoring