add weighted sampling code