Refactor page traversal into a separate object