refactoring cmd tool