Optimal Codebook and its Applications