Reimplement getRandomSample() more efficiently