reusing code for training set