almost there, loops thru region stores results correctly, but there are nans