next refactor