Added code for analysis and simulations