Fixed loop length bug in runSimulation.