Changed if/else/if/else... to switch statement

Also, what's this <code>break</code> doing here?