put `type` on the left side of these comparisons
couldn't this be an else-if?