refactor for sample