added randomsampling