Replace redundant if statements with a proper switch.