outsourced sampling code to cpp| made bv pointer to be able to delete it