Refactored record_training