Pulled a repeated calculation out of for loop.