refactor analysis into sample