Refactor scraper controller code