more work on query analysis