Converted addVariable to use the new query function