When toggling the mode it updates the toggle switch