http://sislands.com/coin70/week6/encoder.htm