Better calculate when to generate all pages in the pagination list instead of just hardcoding a value