improve basic UnionFind