Add query handling