Refactored code.

Refactored code. Took out unnecessary switch statement.