added loop for cross validation