Refactor Database Utils