Add query to output besides NS. Fix when query key is not in operation dict.