refactored database