Fix encoding method