fixing encoding bugs