refactor handleUpdate