private int DeterminePageCount(string productName) { var pageNumber = new PageNumber(); while (!pageNumber.Determined) { var url = BuildUrl(productName, pageNumber.Current); var html = GetHtml(url); if (_scraper.HasProductsToScrape(html)) { pageNumber.Increase(); } else { pageNumber.Decrease(); } } return(pageNumber.Current); }