#14 refactor encoding implementation (9)