Minimal implementation of takeSample