Add sanity check for nil

Prior to this commit we did not next if nil