Fix potential exception in sim.js