fix cross validation by initializing max_idx in subproblem