Improved encoding