database started refactoring