Added function for training on single example