refactor ai