tanjectory code copied into MIPT function