Cleaned up runSim function