Creating codebook