Modified calculation of xidx, yidx, zidx