Updated the Union-find class