fix crash when table is empty;