This same switch structure is repeated in this file no less than three times. There's an opportunity to use polymorphism here instead to avoid the multiple switches.