made the simulation loop a bit tidier