replace an ugly conditional with a nice case statement

never thought i'd say that ...