modify the pre-training function