connected componets calculation redone