Wrap code in anonymous function