add dynamic programming