Cleaned up switch.js