implement train method