updating the codebook