Optimising for loops and fixing == bug.