query parsing improvement