Refactor getenv access