Refactored cli.py