Modified rescale function to normalise probabilities