added subproblem function