Fix query parsing