refactor to use sample method