refactor code, implemented scraping pagination