implement the function that saves simulation results