use switch case instead of key lookup for more type safety.