training function written