adding controlling logic for the simulation