model generator refactoring