refactoring updateTable stuff