Changed the script to find all connected components so it can distinguish multiple components that have data