updated to include codebook