added the new changes to handle proper pagination.
cosmetic changes.