Moved global function to a lambda function hoping that it'll resolve some oddities with std::function