Fixed the search/replace with functions that can be used outside the loop