fix for "invalid byte sequence" error