replaced ugly if structure with switch statement.

Feel slightly like a real programmer...but I have a feeling this is still terribly styled.