add DP implementation, has bug in it, need debug