restrict max page count to avoid infite loop