fixed the fix_invariants method