works for arrays of xy coords