simplified search for NaN errors. print out of total energy has been moved to last trajectory