add matching code for trainingset retrieval