finished simulate() fnction