Use case/when instead of if/elsif in hopes that the compiler
can optimize it somewhat