encode written with Chris