added options to control random sampling