Converting getVariable to use the nnew query function