allow env to be a function