Moved code from main into parseCommand