Added javascript switch method