fixed bug with compute invariants