refactoring code: stringsearch