Simulation Code by Cindy Hui