Fixed bug in training model