Update to sampling function