Use a Map instead of repeated checks