encode bugfix