Is this supposed to be connected?
Removing the widget before attempting all of this isn’t a great idea, because it’s trying to run your code
Better to remove it at the end.