Perform null checks before writing