Refactor If / else blocks slightly

I was trying to imagine how this would work when there are an
unknown number of elsif conditions, and nesting this seemed like the obvious
answer.