DTW pass alg rewritten