factoring out db to decrease locking
travis fix