improvements for Encoding