Fix the search and replace functions