refactor sample