FIxed bug with encoding