Updating the codebook