fix check for null terminator