Move computation of range to its own method.