DP finished. need debug.
Final Version.