Revised QueryHandler