Added functionality to randomly select samples