Initial work on the encoder