working version of training code
fixed merge