utility to build cross validation folds