Refactor: Replace each with map and compare chars with #casecmp