Version with cross-validation