Added code to trainer