Moved switch inside checkKey()