refactor Database class