Refactor parseCommand