Pagination function (not in use yet).