added sampling and adaptive sampling