add exception handling for UnicodeDecodeError