refactoring DisjointSet