split functions between models.py and views.py