Refactor Database