Working dsu algorithm. yay!