fix some bugs in the simulation script