refactoring of db module