added comments of prep_q_encoding