did some refactoring in the db module