write codebook