refactored run switch out into array of function pointers.