better NULL checking in base writer