2 Implement train functions