fixed bug with encoding