some minor changes to simulation.cpp