reworking code to accomodate UnionFindT monad transformer