Finished the first version encoder