what is switch and its functions