improve toggle api