use name[len] in switch directly, instead of creating a shadowed variable.