Adding row ids, extracting table refresh to function