minor refactoring to db lib