Added support for encoding