Fixed bug in standard deviation calculation