Using switch/case instead of repeated if