Update connectivitySwitch.js

Code review
- Be aware of function scope
- Name method with what they do not when they are called
- Put not reusable code in calling code
- Use config object to give not reusable values