write codebook

rewrite codes