rewrite search functionality