refactored page grouping