used the new functor in dynamic programing