Move invariant comparison out of inner drawing loop