added encode (wip)