added time measurement to training function