integrate with union_find