Wrapped code in anonymous function and reduced complexity.