now checking for valid roots before iterating