now actually using sets, though only converting to set at the end