Modify switchVisibility method