Converting variableExists to use the new query function