Fix search and replace functions