Use function pointers instead of a switch/case