Refactoring page iterator class

Removing duplicate code by adding a method consumed by the others.