Fix query in case the table is not found