Use sets to avoid groups with duplicate names
incorrect use of flatten with an array of Sets