fix query logging