fix to different connected_componenets implementation, which now ends up being slower