added union find algorithms