fix a bug in query intersection and complement