fix query parsing