Updated: code used in simulation run