Added modified simulation code