Switched to using boost function for the factory function