Added a more specific check for database existence.