use callback functions instead of one giant switch/case