history query fix