added standard dp algo