Add selectSample and genRandom function