working connected components algorithm, still got all the debug code in