extract variable for performance

I've extracted the process do not need to be run for each loop.