Implemented dynamic time warping