incorporate functions into trjactory class and add example 5.