Cut out a unnecessary conditionals in main function by better using function pointers.