Add a check if table is defined or not before calling setData