Actually it was missing `lastRow = errorRow;` after this instruction you pin-pointed. Now it's ok.