Applying Pagination logic only when there are page numbers on the page