Converted removeVariable to use the new query function