fix a bug in cosSampler