Bugfix for encoding