refactored - turned if/else statement into switch statement