Added checking of database existence