Using invariant instead of warning