Refactor loadPages to load pages from current one