Encoder and Decoder refactored
Succeed in simple encoding scheme