refactor CommandLineHandler's handleCommand method