refactoring on un/train methods