Replacing switch statements for an array lookup