train-data function added