Changed environment ordering for functions