wrote encoder program