finalized dtw_demo.py