fix a bug of scan_idx calculation