implement direct sampling