fix the hardcoding of the number of iterations