sampling implementation