Modify codes to study encoding process