#17 fix bug in sample method
(cherry picked from commit 7249b6a51cd2d025cb8d04590eb8a561f00211ba)