refactored ugly if/else block into table
minor refactor to elinate if statement