alpha of training script done, annoying and ugly, but it works