modified DTW for matching