was comparing the segment with itself (bad index value), adding some defensive code as we can expect nulls now