more efficient

trying to collapse the large if/else statement into small functions