Refactor for update_widgets.