Code necessary to run the simulations