local db refactoring