refactor in the train