use correct maxiter variable