Fixed a missing null check