update BuildCodebook