Fix bug with encoding