Fixed a bug in the trainer