change structure & fix encoding bug