Fixed error in std calculation. THe error came from a bad use of a for loop