factor data lookup branches together
factor out lookups
add a couple of blank lines
break up long lines
short circuit dangling else-branch
move fallback assignment out of if-branch
add a blank line
factor branches together
fix indentation
make branches analogous
move aggregationtype lookup into own function
duplicate return
invert ordering of conditionals
factor together data lookups