Fix range computing algorithm.