refactoring xdb