separate training code to new file