simple dinamyc programming implemented