Updated Query class