Fixed bugs in calculation of current iteration