Added: check the number of dates and stop if greater than the number of products.