New pagination function (still not in use).