Add pagination to search function