a few functions for trajectory