Add maxIteration as a parameter that users can control.