db refactored