refactored and fixed set union