Fixed NPE when the table is empty