Code for simulation for CHH journal version