refactoring for AI