fixed bug when table is empty