check if db exists first