moved db stuff to own file