Added union-find data structure