cached variable inside loop