updated DTW function, still high accuracy