Replace if ... else blocks by switch statements