Finished with pseudo-dynamic proramming