connected components seems to work