moves application logic to models.py