small modification
fixed the crashing simulation with input.