moved db stuff to its own file