genericised sample functions