remove useless code
replace if…else if with switch