Update simulator.java

Fixed null pointer in certain cases