finished saving the trajectory file :  not tested completely