added code for sampling paths