refactoring core engine