Query environment correctly