You need the same check for both key and value, since you are storing it in a StringMap.