refactored code so that we separate test cases into n-folds