Added database exists check