fix codebook