Modification of function and the loop return the good value