refactor function pointer to std::function