basic version of the train method