Updated sim.c