Implement a lot more functionality. Now loop invariant and linear