Added a maximum for returning pages so that the function does not crawl forever