Adding generic toggle function