implement joinSets and tests