move db operations to models.py