Refactored model generator