simulation loop