Fix query variable reference