added support for passing handler an an anonymous function