modified sim_c to be iterative