added support for suppliying a function to extedn