handle encoding better