add onToggle event binding

refactoring