bug fixing; added trajectory measuring for generalization