Another "is None" check, in calculate_gap