Fix bug when checking validity of table name