add back null termination handling