Finish dynamic programming