update train to polymorphic function, It's very cool