added ability to calculate next row