refactor dbmanager