Refactored code in function outcome_products_random.