Wrapping extension in anonymous function