Modified the sampling code in Utility