Added invariant check macro