added n_iterations parameter