fixed double encoding bug