refactoring text parser