fixed bug when there was non-UTF8 input.