added checks for zero standard deviation