Pagination change

Pagination code changed to be more responsive.