almost working `train` method