Merge if statements into a giant else-if statement