Simulation Function updated