logic to run simulation and event management