Refactor acquisition of db object