Add condition to deactivate toggle button
this commit adds a condition to check if the toggle button exists and is currently active before deactivating it. The condition ensures that the toggle button is only deactivated if it meets the specified criteria. This enhancement improves the functionality of the code by providing better control over the toggling behavior.