simplify get_pages function