iteration calculation mistake fixed