added functionality for connected components