updated msd code to handle all of the time steps