adding workaround to handle unexpected '\0' characters in the input.