modification of the pagination to adapt to the number of page to display