Convert if/elseif ladder to a switch stmt