Converted main switch to array of function pointers