Refactoring and adding highlighting of text during search