refactoring and improving
improve errors on input text, cover test