Changed way of simulation from endless loop to timer