Replaced a series of if statements with a switch statement.