I think the problem is with your if and else statements when you check for visibility of the widget. Remove the else and keep the code outside that the widget is now visible and the code could be performed, otherwise, it will just open the widget as the if the statement was true and it won't do the negation of it which is tanning in the else statement...
Also, it would be better if you check that the inventory has the items to be tanned as kind of failsafe and so that it doesn't glitch if you have breaks enabled.