fixing a encoding bug found by James