Slight improvement to zscore algo