minor bug fix in sim.py