Optimized GUI toggle function.