If optouts is a set because of duplicates, should num_optout be calculated on the size of the set?  Actually it looks like it's only used to return a value at the end.  If we want it to be an accurate number, it should be calculated as the change in the to_list before and after being filtered in the next line.  If people opt out and then unenroll, there's no point in counting their optouts.