bug fix in samplling