implemented cross-validation