fixed bug in connected components stop condition