model setup and refactoring