refining reduce() example