refactoring for kfold. Still a lot a things in common btween threeFolds and
kFolds (almost everything, should consider merging it in a proper way)