refactored Db class