Models code refactored