replace deprecated functions in src/sample.jl