Handles the grouping of pages.