created function simulate()