Change to using a switch statement

This will make it easy to update and edit the code in the future.