Added maximum number of iterations