fix encoding method