Added option for encoding.