add db refactor