Rewrote z_score algorithm.