Refactor each invariant check