Moved logic to check if a page is valid or not into the Paginator class