Improved zscore algo