added options for sampling with/without replacement