Added 'num_iter' as an argument to the iteration functions