Added checks before doing toLowerCase on unknown values