generalizes to any set size