Added helper code to perform cross-validation