Added retries, and a loop for getPages