improved environment variable collection