Routine to detect all subregions works now; need to figure out how to merge the ones that are touching