fix encoding phase