maxIterations added as an argument