Explaining the simulation code