Moved the calculation of the ses out of the loop, as it should be