refactor updateTable method