fixed sampling bug