extracted random functions from datagen