moved database stuff to db.py