adding optimization for motion tracking algorithm, not stable right now