Added escape logic to search functionality