Pagination is now its own function

clean clean clean