Tidied up JS switch statements