added missing null reference check