Fixed Simulation and Analysis Code - lapply version