updated cross-validation code