Improved example showing how to register a function.