Refactoring of the toggle button component