polishing the codebook