put calculation out of the loop