Fixed bug in invariant