added a decorator for applying an environment to a function context.