implemented connected components in search