Refactor models.py