reduce else-if blocks