Updated query-object code