Change search function to use paginate properly