Added loop for training examples.