add curve matching algorithm to find the best motion curve