added existential check for db