refactoring db