correct checking for table existence