Improve CommandPrompt class, reducing the code