added brute force invariant checker in start and end of loop