Use some function pointers to clean up switch block