added the UnionFind struct