Simulation code implementation