fix bug in trajectory sampling