Removed duplicate code for Search and Replace