improve environments handling