use getenv/setenv rather than directly modifying environment