Revised the search implementation