Add with_env function.