Added outer loop over all the indices in the watershed.