Code from simulation project.