Refactored the training steps, shoudl be more readable.