refactor toggle.ts