formatting and refactoring to improve and simplify command parsing and execution