add pagination function for search results