fix reshuffling bug when removing queries