fixed some bugs in mean and sd functions