Rewrote the train() function using lambda expression