Some refactoring of parseCommand