Is this code making too many assumptions about optionals being present?